[issue32309] Implement asyncio.run_in_executor shortcut

Paul Martin report at bugs.python.org
Fri Nov 1 07:45:59 EDT 2019


Paul Martin <greatestloginnameever at gmail.com> added the comment:

Good points. I made a mistake in run

Should be:

    async def run(self, func, *args, **kwargs):
        call = functools.partial(func, *args, **kwargs)
        return await self._loop.run_in_executor(self._executor, call)

Also in this case run awaits and returns the result. Yury suggested earlier just to return the future and not await. I have no strong opinion either way. The above example does seem more higher level but Yury's example is more flexible.

I agree that shutdown_default_executor and _do_shutdown should be changed to accept an executor argument so that any executor can be shutdown asynchronously. So the loop API would have a shutdown_executor method. shutdown_default_executor would just call shutdown_executor with the default executor as argument. That would be a good first step.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32309>
_______________________________________


More information about the Python-bugs-list mailing list