@@ -1182,30 +1182,30 @@ async def runner():
1182
1182
@support .requires_fork ()
1183
1183
class TestFork (unittest .IsolatedAsyncioTestCase ):
1184
1184
1185
- @warnings_helper .ignore_fork_in_thread_deprecation_warnings ()
1186
1185
async def test_fork_not_share_event_loop (self ):
1187
- # The forked process should not share the event loop with the parent
1188
- loop = asyncio .get_running_loop ()
1189
- r , w = os .pipe ()
1190
- self .addCleanup (os .close , r )
1191
- self .addCleanup (os .close , w )
1192
- pid = os .fork ()
1193
- if pid == 0 :
1194
- # child
1195
- try :
1196
- loop = asyncio .get_event_loop ()
1197
- os .write (w , b'LOOP:' + str (id (loop )).encode ())
1198
- except RuntimeError :
1199
- os .write (w , b'NO LOOP' )
1200
- except BaseException as e :
1201
- os .write (w , b'ERROR:' + ascii (e ).encode ())
1202
- finally :
1203
- os ._exit (0 )
1204
- else :
1205
- # parent
1206
- result = os .read (r , 100 )
1207
- self .assertEqual (result , b'NO LOOP' )
1208
- wait_process (pid , exitcode = 0 )
1186
+ with warnings_helper .ignore_fork_in_thread_deprecation_warnings ():
1187
+ # The forked process should not share the event loop with the parent
1188
+ loop = asyncio .get_running_loop ()
1189
+ r , w = os .pipe ()
1190
+ self .addCleanup (os .close , r )
1191
+ self .addCleanup (os .close , w )
1192
+ pid = os .fork ()
1193
+ if pid == 0 :
1194
+ # child
1195
+ try :
1196
+ loop = asyncio .get_event_loop ()
1197
+ os .write (w , b'LOOP:' + str (id (loop )).encode ())
1198
+ except RuntimeError :
1199
+ os .write (w , b'NO LOOP' )
1200
+ except BaseException as e :
1201
+ os .write (w , b'ERROR:' + ascii (e ).encode ())
1202
+ finally :
1203
+ os ._exit (0 )
1204
+ else :
1205
+ # parent
1206
+ result = os .read (r , 100 )
1207
+ self .assertEqual (result , b'NO LOOP' )
1208
+ wait_process (pid , exitcode = 0 )
1209
1209
1210
1210
@warnings_helper .ignore_fork_in_thread_deprecation_warnings ()
1211
1211
@hashlib_helper .requires_hashdigest ('md5' )
0 commit comments