[issue33638] condition lock not re-acquired

2018-05-24 Thread christof

New submission from christof :

Hello,

I have a simple code which triggers a timeout if a task did not complete

import asyncio

async def task_timeout():
condition = asyncio.Condition()
with await condition:
try:
await asyncio.wait_for(condition.wait(), timeout=4)
except asyncio.TimeoutError as e:
 
print("timeout reached")
# uncomment this line to make the code work
# await asyncio.sleep(0)


f = asyncio.ensure_future(task_timeout())

loop= asyncio.get_event_loop()
loop.run_until_complete(f)

It throws an exception when leaving the scope for the condition because it 
expects the lock to be acquired:

RuntimeError: Lock is not acquired.

If you uncomment the line to sleep, it will work because it will continue in 
the coroutine Condition.wait and call:
 yield from self.acquire() => locks.py line 355

I think this is a bug and that this behaviour is not the expected one.

--
components: asyncio
messages: 317604
nosy: asvetlov, christof, yselivanov
priority: normal
severity: normal
status: open
title: condition lock not re-acquired
type: behavior
versions: Python 3.6

___
Python tracker 

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



[issue33638] condition lock not re-acquired

2018-05-24 Thread christof

christof  added the comment:

In my previous comment, what I want to implement is not a timeout for a task to 
complete but more precisely a timeout triggered if the coroutine was not wake 
up by a notify on the condition.

--

___
Python tracker 

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



[issue33638] condition lock not re-acquired

2018-05-29 Thread Yury Selivanov


Yury Selivanov  added the comment:

This is caused by wait_for not waiting for the cancelled task.  
https://bugs.python.org/issue32751 tracks that bug.

--
superseder:  -> wait_for(future, ...) should wait for the future (even if a 
timeout occurs)

___
Python tracker 

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



[issue33638] condition lock not re-acquired

2018-05-29 Thread Elvis Pranskevichus


Change by Elvis Pranskevichus :


--
keywords: +patch
pull_requests: +6849
stage:  -> patch review

___
Python tracker 

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



[issue33638] condition lock not re-acquired

2018-05-29 Thread Yury Selivanov


Yury Selivanov  added the comment:


New changeset e2b340ab4196e1beb902327f503574b5d7369185 by Yury Selivanov (Elvis 
Pranskevichus) in branch 'master':
bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216)
https://github.com/python/cpython/commit/e2b340ab4196e1beb902327f503574b5d7369185


--

___
Python tracker 

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



[issue33638] condition lock not re-acquired

2018-05-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +6855

___
Python tracker 

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



[issue33638] condition lock not re-acquired

2018-05-29 Thread miss-islington


miss-islington  added the comment:


New changeset d8948c5e09c4a2a818f6f6cfaf8064f2c2138fa5 by Miss Islington (bot) 
in branch '3.7':
bpo-32751: Wait for task cancellation in asyncio.wait_for() (GH-7216)
https://github.com/python/cpython/commit/d8948c5e09c4a2a818f6f6cfaf8064f2c2138fa5


--
nosy: +miss-islington

___
Python tracker 

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



[issue33638] condition lock not re-acquired

2018-05-29 Thread Yury Selivanov


Change by Yury Selivanov :


--
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