[issue40782] AbstactEventLoop.run_in_executor is listed as an async method, but should actually return a Futrue

2020-08-13 Thread James Barrett


Change by James Barrett :


--
keywords: +patch
pull_requests: +20979
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21852

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40782] AbstactEventLoop.run_in_executor is listed as an async method, but should actually return a Futrue

2020-08-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

I think it makes sense to remove the `async` from the definition in 
AbstractEventLoop.

If you want to help, you can submit a PR to do it.

--
nosy: +gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40782] AbstactEventLoop.run_in_executor is listed as an async method, but should actually return a Futrue

2020-07-01 Thread James Barrett


James Barrett  added the comment:

Is there any further movement on this?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40782] AbstactEventLoop.run_in_executor is listed as an async method, but should actually return a Futrue

2020-05-26 Thread Kyle Stanley


Kyle Stanley  added the comment:

>From looking at the commit history of AbstactEventLoop.run_in_executor(), it 
>seems that it was previously be a non-coroutine method prior to the conversion 
>from the `@asyncio.coroutine` decorator to `async def` (PR-4753). See 
>https://github.com/python/cpython/blame/ede157331b4f9e550334900b3b4de1c8590688de/Lib/asyncio/events.py#L305.

The only context for the change I can find is the following conversation 
between Andrew and Yury: 
https://github.com/python/cpython/pull/4753#issuecomment-350114336. 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?

--
nosy: +aeros, asvetlov, yselivanov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40782] AbstactEventLoop.run_in_executor is listed as an async method, but should actually return a Futrue

2020-05-26 Thread James Barrett


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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com