Skip to content

Commit 5bd9cdd

Browse files
add comments
1 parent aefab6b commit 5bd9cdd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/asyncio/events.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ def __init__(self):
668668
self._local = self._Local()
669669
if hasattr(os, 'fork'):
670670
def on_fork():
671+
# Reset the loop and wakeupfd in the forked child process.
671672
self._local = self._Local()
672673
signal.set_wakeup_fd(-1)
673674

Lib/test/test_asyncio/test_unix_events.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,8 @@ async def runner():
18731873
@unittest.skipUnless(hasattr(os, 'fork'), 'requires os.fork()')
18741874
class TestFork(unittest.IsolatedAsyncioTestCase):
18751875

1876-
async def test_fork(self):
1876+
async def test_fork_not_share_event_loop(self):
1877+
# The forked process should not share the event loop with the parent
18771878
loop = asyncio.get_running_loop()
18781879
r, w = os.pipe()
18791880
self.addCleanup(os.close, r)
@@ -1893,6 +1894,8 @@ async def test_fork(self):
18931894
wait_process(pid, exitcode=0)
18941895

18951896
def test_fork_signal_handling(self):
1897+
# Sending signals to the forked process should not affect the parent
1898+
# process.
18961899
multiprocessing.set_start_method('fork')
18971900
manager = multiprocessing.Manager()
18981901
self.addCleanup(manager.shutdown)

0 commit comments

Comments
 (0)