File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ def __getstate__(self):
103
103
if sys .platform == 'win32' :
104
104
h = context .get_spawning_popen ().duplicate_for_child (sl .handle )
105
105
else :
106
- if self . is_fork_ctx :
106
+ if getattr ( self , " is_fork_ctx" , False ) :
107
107
raise RuntimeError ('A SemLock created in a fork context is being '
108
108
'shared with a process in a spawn context. This is '
109
109
'not supported. Please use the same context to create '
Original file line number Diff line number Diff line change @@ -5342,6 +5342,16 @@ def test_ignore_listener(self):
5342
5342
finally :
5343
5343
conn .close ()
5344
5344
5345
+ # Utility functions used as target for spawn Process
5346
+ def put_one_in_queue (queue ):
5347
+ queue .put (1 )
5348
+
5349
+ def put_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
+
5345
5355
class TestStartMethod (unittest .TestCase ):
5346
5356
@classmethod
5347
5357
def _check_context (cls , conn ):
@@ -5443,6 +5453,19 @@ def test_mixed_startmethod(self):
5443
5453
p .start ()
5444
5454
p .join ()
5445
5455
5456
+ def test_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
+ while not queue .empty ():
5465
+ results .append (queue .get ())
5466
+
5467
+ self .assertEqual (results , [2 , 1 ])
5468
+
5446
5469
5447
5470
@unittest .skipIf (sys .platform == "win32" ,
5448
5471
"test semantics don't make sense on Windows" )
You can’t perform that action at this time.
0 commit comments