summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing
diff options
context:
space:
mode:
authorJesse Noller <jnoller@gmail.com>2009-08-06 02:05:56 (GMT)
committerJesse Noller <jnoller@gmail.com>2009-08-06 02:05:56 (GMT)
commit8497efeb4064be366a76e50a8650ed4b6dd3fd01 (patch)
tree570fa25975a876863aac029763288b4b7eef61ec /Lib/multiprocessing
parent175e0bf8ca4934fd4f360cc403e209b671a162a9 (diff)
downloadcpython-8497efeb4064be366a76e50a8650ed4b6dd3fd01.zip
cpython-8497efeb4064be366a76e50a8650ed4b6dd3fd01.tar.gz
cpython-8497efeb4064be366a76e50a8650ed4b6dd3fd01.tar.bz2
Fix issue 4660: spurious task_done errors in multiprocessing, remove doc note for from_address
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r--Lib/multiprocessing/queues.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
index 5df5882..ea27991 100644
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -282,9 +282,22 @@ class JoinableQueue(Queue):
Queue.__setstate__(self, state[:-2])
self._cond, self._unfinished_tasks = state[-2:]
- def put(self, item, block=True, timeout=None):
- Queue.put(self, item, block, timeout)
- self._unfinished_tasks.release()
+ def put(self, obj, block=True, timeout=None):
+ assert not self._closed
+ if not self._sem.acquire(block, timeout):
+ raise Full
+
+ self._notempty.acquire()
+ self._cond.acquire()
+ try:
+ if self._thread is None:
+ self._start_thread()
+ self._buffer.append(obj)
+ self._unfinished_tasks.release()
+ self._notempty.notify()
+ finally:
+ self._cond.release()
+ self._notempty.release()
def task_done(self):
self._cond.acquire()