[issue26552] Failing ensure_future still creates a Task

2022-01-28 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset a5451c96a14ac0c3ee7cef7b5c52ab1d783ec613 by Kumar Aditya in 
branch '3.10':
bpo-26552: Fixed case where failing `asyncio.ensure_future` did not close the 
coroutine (#30288) (#31003)
https://github.com/python/cpython/commit/a5451c96a14ac0c3ee7cef7b5c52ab1d783ec613


--

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2022-01-28 Thread Kumar Aditya


Change by Kumar Aditya :


--
pull_requests: +29185
pull_request: https://github.com/python/cpython/pull/31003

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2022-01-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks Kumar for the fix!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2022-01-28 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 24cc6411adbfeecd8901f1ea50caa414c908 by Kumar Aditya in 
branch 'main':
bpo-26552: Fixed case where failing `asyncio.ensure_future` did not close the 
coroutine (#30288)
https://github.com/python/cpython/commit/24cc6411adbfeecd8901f1ea50caa414c908


--

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2022-01-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

So I just realized that the OP's description is slightly misleading. (Their 
code is spot on though!)

The code does not create an unwaited-for *task*, assuming that "task" refers to 
the asyncio.Task class.

What is created is a *coroutine* object that's never awaited (as the quoted 
RuntimeWarning message says: "coroutine 'foo' was never awaited").

So the thing that needs to be closed in the bowels of _ensure_future() is 
indeed the argument (coro_or_future), in case it is a coroutine object.

--

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2021-12-29 Thread Kumar Aditya


Change by Kumar Aditya :


--
nosy: +kumaraditya303
nosy_count: 5.0 -> 6.0
pull_requests: +28502
pull_request: https://github.com/python/cpython/pull/30288

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2021-12-29 Thread Carlos Damázio

Change by Carlos Damázio :


--
keywords: +patch
nosy: +dmzz
nosy_count: 4.0 -> 5.0
pull_requests: +28501
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30287

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2021-11-29 Thread Guido van Rossum


Change by Guido van Rossum :


--
keywords: +easy

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2021-11-29 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2021-11-29 Thread Irit Katriel


Irit Katriel  added the comment:

Reproduced on 3.11.

--
nosy: +iritkatriel
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.5

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2016-03-13 Thread Guido van Rossum

Guido van Rossum added the comment:

Sounds like an easy fix. Could you submit a patch?

--

___
Python tracker 

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



[issue26552] Failing ensure_future still creates a Task

2016-03-13 Thread Damien Nicolas

New submission from Damien Nicolas:

When calling asyncio.ensure_future() on a coroutine, and if the loop is closed, 
ensure_future() will raise a RuntimeError. 

However, it still creates a Task, which will generate a RuntimeWarning that we 
can’t fix since there is no way to cancel the Task.

Here is the code to reproduce the bug:


import asyncio

l = asyncio.get_event_loop()
l.close()

async def foo():
pass

try:
# Since the exception raises here, fut is never set
# so we can't call fut.cancel()
fut = asyncio.ensure_future(foo())
except RuntimeError:
pass


# stderr:
# aio.py:12: RuntimeWarning: coroutine 'foo' was never awaited
#   pass

--
components: asyncio
messages: 261696
nosy: gordon, gvanrossum, haypo, yselivanov
priority: normal
severity: normal
status: open
title: Failing ensure_future still creates a Task
type: behavior
versions: Python 3.5

___
Python tracker 

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