MCPcopy Create free account
hub / github.com/python/cpython / test_fork_asyncio_run

Method test_fork_asyncio_run

Lib/test/test_asyncio/test_unix_events.py:1297–1313  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1295 @hashlib_helper.requires_hashdigest('md5')
1296 @support.skip_if_sanitizer("TSAN doesn't support threads after fork", thread=True)
1297 def test_fork_asyncio_run(self):
1298 self.addCleanup(multiprocessing_cleanup_tests)
1299
1300 ctx = multiprocessing.get_context('fork')
1301 manager = ctx.Manager()
1302 self.addCleanup(manager.shutdown)
1303 result = manager.Value('i', 0)
1304
1305 async def child_main():
1306 await asyncio.sleep(0.1)
1307 result.value = 42
1308
1309 process = ctx.Process(target=lambda: asyncio.run(child_main()))
1310 process.start()
1311 process.join()
1312
1313 self.assertEqual(result.value, 42)
1314
1315 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
1316 @hashlib_helper.requires_hashdigest('md5')

Callers

nothing calls this directly

Calls 9

addCleanupMethod · 0.80
ManagerMethod · 0.80
ValueMethod · 0.80
get_contextMethod · 0.45
ProcessMethod · 0.45
runMethod · 0.45
startMethod · 0.45
joinMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected