Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f8904e9

Browse files
Issue #22853: Added regression test for using multiprocessing.Queue at import
time. Patch by Davin Potts.
1 parent c19ed37 commit f8904e9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lib/test/_test_multiprocessing.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,27 @@ def test_task_done(self):
713713
for p in workers:
714714
p.join()
715715

716+
def test_no_import_lock_contention(self):
717+
with test.support.temp_cwd():
718+
module_name = 'imported_by_an_imported_module'
719+
with open(module_name + '.py', 'w') as f:
720+
f.write("""if 1:
721+
import multiprocessing
722+
723+
q = multiprocessing.Queue()
724+
q.put('knock knock')
725+
q.get(timeout=3)
726+
q.close()
727+
del q
728+
""")
729+
730+
with test.support.DirsOnSysPath(os.getcwd()):
731+
try:
732+
__import__(module_name)
733+
except pyqueue.Empty:
734+
self.fail("Probable regression on import lock contention;"
735+
" see Issue #22853")
736+
716737
def test_timeout(self):
717738
q = multiprocessing.Queue()
718739
start = time.time()

0 commit comments

Comments
 (0)