[issue44371] asyncio.wait_for does not cancel running tasks in the correct fashion

2021-06-19 Thread Ofek Kirzner


Ofek Kirzner  added the comment:

Kindly reminder.
Thx :)

--
resolution:  -> remind

___
Python tracker 

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



[issue44371] asyncio.wait_for does not cancel running tasks in the correct fashion

2021-06-09 Thread Ofek Kirzner


New submission from Ofek Kirzner :

Following https://bugs.python.org/issue32751 I think wait_for should also wait 
for running coroutine in case it has been cancelled.

Example code:

import asyncio


async def inner():
try:
print(1)
await asyncio.sleep(3600)
print(2)
except asyncio.CancelledError:
print('inner - canc')
raise


async def outer(f):
try:
print('a')
# Version 1 - This creates the expected behaviour
# await f
# Version 2 - This creates the reversed behaviour
await asyncio.wait_for(f, timeout=500)
print('b')
except asyncio.CancelledError:
print('outer - canc')


@pytest.mark.asyncio
async def test_t1():
t = asyncio.create_task(outer(inner()))
done, pending = await asyncio.wait([t], timeout=1)
t.cancel()

await t

--
I expect inner to be cancelled and awaited before outer is finished.
i.e., exepcted output:
1
inner - canc
outer - canc


While I get:
1
outer - canc
inner - canc

--
components: asyncio
messages: 395505
nosy: asvetlov, ofekkir, yselivanov
priority: normal
severity: normal
status: open
title: asyncio.wait_for does not cancel running tasks in the correct fashion
type: behavior
versions: Python 3.8

___
Python tracker 

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