File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,12 +140,18 @@ Running and stopping the loop
140140 The loop must not be running when this function is called.
141141 Any pending callbacks will be discarded.
142142
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.
145146
146147 This method is idempotent and irreversible. No other methods
147148 should be called after the event loop is closed.
148149
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+
149155.. coroutinemethod :: loop.shutdown_asyncgens()
150156
151157 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):
380380class BaseEventLoop (events .AbstractEventLoop ):
381381
382382 def __init__ (self ):
383+ # If true, close() waits for the default executor to finish
384+ self .wait_executor_on_close = True
383385 self ._timer_cancelled_count = 0
384386 self ._closed = False
385387 self ._stopping = False
@@ -635,7 +637,7 @@ def close(self):
635637 executor = self ._default_executor
636638 if executor is not None :
637639 self ._default_executor = None
638- executor .shutdown (wait = False )
640+ executor .shutdown (wait = self . wait_executor_on_close )
639641
640642 def is_closed (self ):
641643 """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