summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-07-10 10:45:21 (GMT)
committerGitHub <noreply@github.com>2017-07-10 10:45:21 (GMT)
commit3b69d911c57ef591ac0c0f47a66dbcad8337f33a (patch)
treeb4c9fc10ede957175251625355056c0c48ab4af7
parent7e60192fe0dfd763b0d458cf0898ba4f7ac7d81a (diff)
downloadcpython-3b69d911c57ef591ac0c0f47a66dbcad8337f33a.zip
cpython-3b69d911c57ef591ac0c0f47a66dbcad8337f33a.tar.gz
cpython-3b69d911c57ef591ac0c0f47a66dbcad8337f33a.tar.bz2
bpo-30886: Fix multiprocessing.Queue.join_thread() (#2642)
multiprocessing.Queue.join_thread() now waits until the thread completes, even if the thread was started by the same process which created the queue. Fix the following warning which occurs randomly when running test_handle_called_with_mp_queue of test_logging.QueueListenerTest: Warning -- threading_cleanup() failed to cleanup -1 threads after 4 sec (count: 0, dangling: 1)
-rw-r--r--Lib/multiprocessing/queues.py9
-rw-r--r--Misc/NEWS.d/next/Library/2017-07-10-12-14-22.bpo-30886.nqQj34.rst3
2 files changed, 4 insertions, 8 deletions
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
index 90844fe..513807c 100644
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -169,14 +169,7 @@ class Queue(object):
self._thread.start()
debug('... done self._thread.start()')
- # On process exit we will wait for data to be flushed to pipe.
- #
- # However, if this process created the queue then all
- # processes which use the queue will be descendants of this
- # process. Therefore waiting for the queue to be flushed
- # is pointless once all the child processes have been joined.
- created_by_this_process = (self._opid == os.getpid())
- if not self._joincancelled and not created_by_this_process:
+ if not self._joincancelled:
self._jointhread = Finalize(
self._thread, Queue._finalize_join,
[weakref.ref(self._thread)],
diff --git a/Misc/NEWS.d/next/Library/2017-07-10-12-14-22.bpo-30886.nqQj34.rst b/Misc/NEWS.d/next/Library/2017-07-10-12-14-22.bpo-30886.nqQj34.rst
new file mode 100644
index 0000000..fedd6cd
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2017-07-10-12-14-22.bpo-30886.nqQj34.rst
@@ -0,0 +1,3 @@
+Fix multiprocessing.Queue.join_thread(): it now waits until the thread
+completes, even if the thread was started by the same process which created
+the queue.