mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
78c7d52779
commit
0f0a30f4da
3 changed files with 15 additions and 3 deletions
|
@ -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."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue