summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/runners.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio/runners.py')
-rw-r--r--Lib/asyncio/runners.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/asyncio/runners.py b/Lib/asyncio/runners.py
index a19a7f9..b3e0c44 100644
--- a/Lib/asyncio/runners.py
+++ b/Lib/asyncio/runners.py
@@ -115,8 +115,6 @@ class Runner:
self._interrupt_count = 0
try:
- if self._set_event_loop:
- events.set_event_loop(self._loop)
return self._loop.run_until_complete(task)
except exceptions.CancelledError:
if self._interrupt_count > 0:
@@ -137,7 +135,11 @@ class Runner:
return
if self._loop_factory is None:
self._loop = events.new_event_loop()
- self._set_event_loop = True
+ if not self._set_event_loop:
+ # Call set_event_loop only once to avoid calling
+ # attach_loop multiple times on child watchers
+ events.set_event_loop(self._loop)
+ self._set_event_loop = True
else:
self._loop = self._loop_factory()
if self._debug is not None: