New submission from James Barrett :
As discussed in <
https://github.com/python/typeshed/issues/3999#issuecomment-634097968 > the
type of `AbstractEventLoop.run_in_executor` is defined at <
https://github.com/python/cpython/blob/master/Lib/asyncio/events.py#L286 > as
follows:
```
async def run_in_executor(self, executor, func, *args):
raise NotImplementedError
```
However all concrete implementations of this method are actually not async
methods but rather synchronous methods which return a Future object.
Logically this appears to make sense: at base `run_in_executor` is not a
coroutine, since it doesn't create an object representing code which will be
executed when the object is awaited, rather it returns an object representing
code which is running asynchronously elsewhere (on another thread) and which
can be awaited to wait for that other thread to complete its task. Which seems
to be a perfect match to what a Future object is supposed to be.
As such it seems that the current definition of the method as a coroutine is
possibly a mistake.
Alternatively if some feel that it is important to allow concrete
implementations to implement it as a coroutine if they need to then perhaps it
could be specified to be a method returning an Awaitable, since that would
cover both options?
--
components: Library (Lib)
messages: 370005
nosy: jamesba
priority: normal
severity: normal
status: open
title: AbstactEventLoop.run_in_executor is listed as an async method, but
should actually return a Futrue
type: behavior
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python
3.9
___
Python tracker
<https://bugs.python.org/issue40782>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com