diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-08-15 22:32:47 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-15 10:02:47 -0700 |
commit | 914f6367a0d015986dafa7a9d542e24192753b6b (patch) | |
tree | 213d940fc16cdfdb81d55bd5c608c09fe24020c6 /Lib/asyncio | |
parent | 2fa03b1b0708d5d74630c351ec9abd2aac7550da (diff) | |
download | cpython-914f6367a0d015986dafa7a9d542e24192753b6b.tar.gz cpython-914f6367a0d015986dafa7a9d542e24192753b6b.zip |
GH-95899: fix asyncio.Runner to call set_event_loop only once (#95900)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/runners.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/asyncio/runners.py b/Lib/asyncio/runners.py index a8b74d532fc..840b133df83 100644 --- a/Lib/asyncio/runners.py +++ b/Lib/asyncio/runners.py @@ -114,8 +114,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: @@ -136,7 +134,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: |