Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(94458)

Unified Diff: Lib/asyncio/selector_events.py

Issue 21998: asyncio: a new self-pipe should be created in the child process after fork
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/asyncio/proactor_events.py ('k') | Lib/asyncio/unix_events.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/asyncio/selector_events.py Thu Feb 05 11:46:45 2015 +0100
+++ b/Lib/asyncio/selector_events.py Thu Feb 05 12:02:08 2015 +0100
@@ -94,6 +94,8 @@ class BaseSelectorEventLoop(base_events.
raise RuntimeError("Cannot close a running event loop")
if self.is_closed():
return
+ # detect fork before using the self-pipe or the selector
+ self._detect_fork()
self._close_self_pipe()
super().close()
if self._selector is not None:
@@ -135,6 +137,9 @@ class BaseSelectorEventLoop(base_events.
break
def _write_to_self(self):
+ # detect fork before using the self-pipe
+ self._detect_fork()
+
# This may be called from a different thread, possibly after
# _close_self_pipe() has been called or even while it is
# running. Guard for self._csock being None or closed. When
@@ -230,6 +235,8 @@ class BaseSelectorEventLoop(base_events.
"""Add a reader callback."""
self._check_closed()
handle = events.Handle(callback, args, self)
+ # detect fork before using the selector
+ self._detect_fork()
try:
key = self._selector.get_key(fd)
except KeyError:
@@ -246,6 +253,8 @@ class BaseSelectorEventLoop(base_events.
"""Remove a reader callback."""
if self.is_closed():
return False
+ # detect fork before using the selector
+ self._detect_fork()
try:
key = self._selector.get_key(fd)
except KeyError:
@@ -268,6 +277,8 @@ class BaseSelectorEventLoop(base_events.
"""Add a writer callback.."""
self._check_closed()
handle = events.Handle(callback, args, self)
+ # detect fork before using the selector
+ self._detect_fork()
try:
key = self._selector.get_key(fd)
except KeyError:
@@ -284,6 +295,8 @@ class BaseSelectorEventLoop(base_events.
"""Remove a writer callback."""
if self.is_closed():
return False
+ # detect fork before using the selector
+ self._detect_fork()
try:
key = self._selector.get_key(fd)
except KeyError:
« no previous file with comments | « Lib/asyncio/proactor_events.py ('k') | Lib/asyncio/unix_events.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+