Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9d43084

Browse files
committed
Support nesting and add test
1 parent4116592 commit9d43084

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

‎Lib/multiprocessing/synchronize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def __getstate__(self):
103103
ifsys.platform=='win32':
104104
h=context.get_spawning_popen().duplicate_for_child(sl.handle)
105105
else:
106-
ifself.is_fork_ctx:
106+
ifgetattr(self,"is_fork_ctx",False):
107107
raiseRuntimeError('A SemLock created in a fork context is being '
108108
'shared with a process in a spawn context. This is '
109109
'not supported. Please use the same context to create '

‎Lib/test/_test_multiprocessing.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5342,6 +5342,16 @@ def test_ignore_listener(self):
53425342
finally:
53435343
conn.close()
53445344

5345+
# Utility functions used as target for spawn Process
5346+
defput_one_in_queue(queue):
5347+
queue.put(1)
5348+
5349+
defput_two_and_nest_once(queue):
5350+
queue.put(2)
5351+
process=multiprocessing.Process(target=put_one_in_queue,args=(queue,))
5352+
process.start()
5353+
process.join()
5354+
53455355
classTestStartMethod(unittest.TestCase):
53465356
@classmethod
53475357
def_check_context(cls,conn):
@@ -5443,6 +5453,19 @@ def test_mixed_startmethod(self):
54435453
p.start()
54445454
p.join()
54455455

5456+
deftest_nested_startmethod(self):
5457+
queue=multiprocessing.Queue()
5458+
5459+
process=multiprocessing.Process(target=put_two_and_nest_once,args=(queue,))
5460+
process.start()
5461+
process.join()
5462+
5463+
results= []
5464+
whilenotqueue.empty():
5465+
results.append(queue.get())
5466+
5467+
self.assertEqual(results, [2,1])
5468+
54465469

54475470
@unittest.skipIf(sys.platform=="win32",
54485471
"test semantics don't make sense on Windows")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp