File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -140,12 +140,18 @@ Running and stopping the loop
140
140
The loop must not be running when this function is called.
141
141
Any pending callbacks will be discarded.
142
142
143
- This method clears all queues and shuts down the executor, but does
144
- not wait for the executor to finish.
143
+ This method clears all queues and shuts down the default executor. By
144
+ default, it waits for the default executor to finish. Set
145
+ *loop.wait_executor_on_close * to ``False `` to not wait for the executor.
145
146
146
147
This method is idempotent and irreversible. No other methods
147
148
should be called after the event loop is closed.
148
149
150
+ .. versionchanged :: 3.8
151
+ The method now waits for the default executor to finish by default.
152
+ Added *loop.wait_executor_on_close * attribute.
153
+
154
+
149
155
.. coroutinemethod :: loop.shutdown_asyncgens()
150
156
151
157
Schedule all currently open :term: `asynchronous generator ` objects to
Original file line number Diff line number Diff line change @@ -380,6 +380,8 @@ async def wait_closed(self):
380
380
class BaseEventLoop (events .AbstractEventLoop ):
381
381
382
382
def __init__ (self ):
383
+ # If true, close() waits for the default executor to finish
384
+ self .wait_executor_on_close = True
383
385
self ._timer_cancelled_count = 0
384
386
self ._closed = False
385
387
self ._stopping = False
@@ -635,7 +637,7 @@ def close(self):
635
637
executor = self ._default_executor
636
638
if executor is not None :
637
639
self ._default_executor = None
638
- executor .shutdown (wait = False )
640
+ executor .shutdown (wait = self . wait_executor_on_close )
639
641
640
642
def is_closed (self ):
641
643
"""Returns True if the event loop was closed."""
Original file line number Diff line number Diff line change
1
+ :mod: `asyncio `: ``loop.close() `` now waits for the default executor to
2
+ finish by default. Set ``loop.wait_executor_on_close `` attribute to
3
+ ``False `` to opt-in for Python 3.7 behavior (not wait for the executor to
4
+ finish).
You can’t perform that action at this time.
0 commit comments