You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=<Date2020-08-17.14:41:46.469>created_at=<Date2020-05-26.15:45:38.680>labels= ['type-bug', '3.8', '3.9', '3.10', '3.7', 'library', 'expert-asyncio']
title='AbstactEventLoop.run_in_executor is listed as an async method, but should actually return a Future'updated_at=<Date2020-08-17.14:41:46.468>user='https://github.com/jamesba'
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?
The only context for the change I can find is the following conversation between Andrew and Yury: #4753 (comment). However, the example provided of connect_read_pipe() had already been a coroutine at the time for the BaseEventLoop implementation, which makes sense in that case. So, it's not clear to me as to why run_in_executor() was also converted to "async def" when its main implementation is not a coroutine. Furthermore, it's documented as an awaitable rather than a coroutine (https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor).
@andrew do you have any additional context to provide that I'm potentially missing?