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

Unified Diff: Lib/asyncio/base_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 | « no previous file | Lib/asyncio/proactor_events.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/asyncio/base_events.py Thu Feb 05 11:46:45 2015 +0100
+++ b/Lib/asyncio/base_events.py Thu Feb 05 12:02:08 2015 +0100
@@ -189,6 +189,7 @@ class BaseEventLoop(events.AbstractEvent
# Identifier of the thread running the event loop, or None if the
# event loop is not running
self._thread_id = None
+ self._pid = os.getpid()
self._clock_resolution = time.get_clock_info('monotonic').resolution
self._exception_handler = None
self._debug = (not sys.flags.ignore_environment
@@ -203,6 +204,15 @@ class BaseEventLoop(events.AbstractEvent
% (self.__class__.__name__, self.is_running(),
self.is_closed(), self.get_debug()))
+ def _detect_fork(self):
+ pid = os.getpid()
+ if pid != self._pid:
+ self._pid = pid
+ self._at_fork()
+
+ def _at_fork(self):
+ pass
+
def create_task(self, coro):
"""Schedule a coroutine object.
@@ -1112,6 +1122,9 @@ class BaseEventLoop(events.AbstractEvent
when = self._scheduled[0]._when
timeout = max(0, when - self.time())
+ # detect fork before using the selector
+ self._detect_fork()
+
if self._debug and timeout != 0:
t0 = self.time()
event_list = self._selector.select(timeout)
« no previous file with comments | « no previous file | Lib/asyncio/proactor_events.py » ('j') | no next file with comments »

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