Kyle Stanley <aeros...@gmail.com> added the comment:

> Is the new asyncio.loop.shutdown_default_executor() suitable for event loops 
> that are run in single-step mode?

I honestly can't say for certain; the primary intended use case for 
shutdown_default_executor() was to provide a means of properly finalizing the 
resources associated with the default executor without blocking the event loop, 
notably the threads in the ThreadPoolExecutor (which were intermittently left 
dangling).  So, when working on the implementation w/ Yury and Andrew, I did 
not strongly consider single-step event loops. I was more concerned with how it 
fit in with asyncio.run() and safe finalization of executor resources. See 
https://bugs.python.org/issue34037 for context.

If you have a recommendation for a change to the current version 
shutdown_default_executor() that would help provide compatibility with 
single-step event loops without hindering the primary goals, I'm sure it would 
be considered.

> Also, what happens to pending executor futures?

When using `loop.shutdown_default_executor()`, it calls 
executor.shutdown(wait=True), which waits for submitted futures to the executor 
to complete before joining the executor's workers (regardless of whether 
they're threads or processes). So, the executor should not be terminated prior 
to the pending futures being completed.

>From a glance at the example code posted above, it seems like it would be 
>incompatible with asyncio.run(), which is a requirement for 
>shutdown_default_executor(). See 
>https://github.com/python/cpython/blob/b9c46a2c2d7fc68457bff641f78932d66f5e5f59/Lib/asyncio/runners.py#L8.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40357>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to