Skip to content

Commit 8497efe

Browse files
committed
Fix issue 4660: spurious task_done errors in multiprocessing, remove doc note for from_address
1 parent 175e0bf commit 8497efe

4 files changed

Lines changed: 20 additions & 8 deletions

File tree

Doc/library/multiprocessing.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,11 +1153,6 @@ their parent process exits. The manager classes are defined in the
11531153

11541154
Run the server in the current process.
11551155

1156-
.. method:: from_address(address, authkey)
1157-
1158-
A class method which creates a manager object referring to a pre-existing
1159-
server process which is using the given address and authentication key.
1160-
11611156
.. method:: get_server()
11621157

11631158
Returns a :class:`Server` object which represents the actual server under

Lib/multiprocessing/queues.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,22 @@ def __setstate__(self, state):
282282
Queue.__setstate__(self, state[:-2])
283283
self._cond, self._unfinished_tasks = state[-2:]
284284

285-
def put(self, item, block=True, timeout=None):
286-
Queue.put(self, item, block, timeout)
287-
self._unfinished_tasks.release()
285+
def put(self, obj, block=True, timeout=None):
286+
assert not self._closed
287+
if not self._sem.acquire(block, timeout):
288+
raise Full
289+
290+
self._notempty.acquire()
291+
self._cond.acquire()
292+
try:
293+
if self._thread is None:
294+
self._start_thread()
295+
self._buffer.append(obj)
296+
self._unfinished_tasks.release()
297+
self._notempty.notify()
298+
finally:
299+
self._cond.release()
300+
self._notempty.release()
288301

289302
def task_done(self):
290303
self._cond.acquire()

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ Craig McPheeters
485485
Lambert Meertens
486486
Bill van Melle
487487
Lucas Prado Melo
488+
Brian Merrell
488489
Luke Mewburn
489490
Mike Meyer
490491
Steven Miale

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ Core and Builtins
354354
Library
355355
-------
356356

357+
- Issue #4660: If a multiprocessing.JoinableQueue.put() was preempted, it was
358+
possible to get a spurious 'task_done() called too many times' error.
359+
357360
- Issue #6595: The Decimal constructor now allows arbitrary Unicode
358361
decimal digits in input, as recommended by the standard. Previously
359362
it was restricted to accepting [0-9].

0 commit comments

Comments
 (0)