summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_events.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-06-03 21:31:04 (GMT)
committerGitHub <noreply@github.com>2019-06-03 21:31:04 (GMT)
commit0f0a30f4da4b529e0f7df857b9f575b231b32758 (patch)
treec76047e9485f288977fb55e076b0f26eb3455ebd /Lib/asyncio/base_events.py
parent78c7d527799dacca91b9ed67057cb996efe526b0 (diff)
downloadcpython-0f0a30f4da4b529e0f7df857b9f575b231b32758.zip
cpython-0f0a30f4da4b529e0f7df857b9f575b231b32758.tar.gz
cpython-0f0a30f4da4b529e0f7df857b9f575b231b32758.tar.bz2
bpo-34037, asyncio: add BaseEventLoop.wait_executor_on_close (GH-13786)
Add BaseEventLoop.wait_executor_on_close attribute: true by default. loop.close() now waits for the default executor to finish by default. Set loop.wait_executor_on_close attribute to False to not wait for the executor.
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r--Lib/asyncio/base_events.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index e002539..b1a7f88 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -380,6 +380,8 @@ class Server(events.AbstractServer):
class BaseEventLoop(events.AbstractEventLoop):
def __init__(self):
+ # If true, close() waits for the default executor to finish
+ self.wait_executor_on_close = True
self._timer_cancelled_count = 0
self._closed = False
self._stopping = False
@@ -635,7 +637,7 @@ class BaseEventLoop(events.AbstractEventLoop):
executor = self._default_executor
if executor is not None:
self._default_executor = None
- executor.shutdown(wait=False)
+ executor.shutdown(wait=self.wait_executor_on_close)
def is_closed(self):
"""Returns True if the event loop was closed."""