[Python-checkins] cpython (2.7): Issue #22853: Fixed a deadlock when use multiprocessing.Queue at import time.
serhiy.storchaka
python-checkins at python.org
Fri Mar 6 21:34:31 CET 2015
https://hg.python.org/cpython/rev/069c13ca7a70
changeset: 94885:069c13ca7a70
branch: 2.7
parent: 94881:f31b91b6683a
user: Serhiy Storchaka <storchaka at gmail.com>
date: Fri Mar 06 22:17:25 2015 +0200
summary:
Issue #22853: Fixed a deadlock when use multiprocessing.Queue at import time.
Patch by Florian Finkernagel and Davin Potts.
files:
Lib/multiprocessing/queues.py | 10 ++++------
Lib/test/test_multiprocessing.py | 20 ++++++++++++++++++++
Misc/ACKS | 2 ++
Misc/NEWS | 3 +++
4 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -44,10 +44,10 @@
from Queue import Empty, Full
import _multiprocessing
-from multiprocessing import Pipe
-from multiprocessing.synchronize import Lock, BoundedSemaphore, Semaphore, Condition
-from multiprocessing.util import debug, info, Finalize, register_after_fork
-from multiprocessing.forking import assert_spawning
+from . import Pipe
+from .synchronize import Lock, BoundedSemaphore, Semaphore, Condition
+from .util import debug, info, Finalize, register_after_fork, is_exiting
+from .forking import assert_spawning
#
# Queue type using a pipe, buffer and thread
@@ -229,8 +229,6 @@
@staticmethod
def _feed(buffer, notempty, send, writelock, close):
debug('starting thread to feed data to pipe')
- from .util import is_exiting
-
nacquire = notempty.acquire
nrelease = notempty.release
nwait = notempty.wait
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -620,6 +620,26 @@
for p in workers:
p.join()
+ def test_no_import_lock_contention(self):
+ with test_support.temp_cwd():
+ module_name = 'imported_by_an_imported_module'
+ with open(module_name + '.py', 'w') as f:
+ f.write("""if 1:
+ import multiprocessing
+
+ q = multiprocessing.Queue()
+ q.put('knock knock')
+ q.get(timeout=3)
+ q.close()
+ """)
+
+ with test_support.DirsOnSysPath(os.getcwd()):
+ try:
+ __import__(module_name)
+ except Queue.Empty:
+ self.fail("Probable regression on import lock contention;"
+ " see Issue #22853")
+
#
#
#
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -411,6 +411,7 @@
Anastasia Filatova
Tomer Filiba
Jeffrey Finkelstein
+Florian Finkernagel
Russell Finn
Dan Finnie
Nils Fischbeck
@@ -1073,6 +1074,7 @@
Iustin Pop
Claudiu Popa
John Popplewell
+Davin Potts
Guillaume Pratte
Amrit Prem
Paul Prescod
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,9 @@
Library
-------
+- Issue #22853: Fixed a deadlock when use multiprocessing.Queue at import time.
+ Patch by Florian Finkernagel and Davin Potts.
+
- Issue #23476: In the ssl module, enable OpenSSL's X509_V_FLAG_TRUSTED_FIRST
flag on certificate stores when it is available.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list