[issue39386] getting invalid data from async iterator

2020-01-20 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Thanks for the report.

Your example could be boiled down to the following:

coro = asynciter()
await coro
await coro

The second call incorrectly returns None but should raise an exception, double 
awaiting is a programming error.

For regular async functions it raises "RuntimeError: cannot reuse already 
awaited coroutine"

--
stage:  -> needs patch

___
Python tracker 

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



[issue39386] getting invalid data from async iterator

2020-01-18 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
components: +asyncio
nosy: +asvetlov, yselivanov

___
Python tracker 

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



[issue39386] getting invalid data from async iterator

2020-01-18 Thread John-Mark Gurney


New submission from John-Mark Gurney :

If I create a coro from an async iterator, then wait_for it w/ a timeout, but 
shielded, so it won't get canceled, and then await upon it, it returns invalid 
data.

See the attached test case.

The reason I do the following is to make sure that an async iterator that I 
have written doesn't return data early, and needs to wait till later.  If I 
didn't shield it, then the async iterator would get cancelled, and I don't want 
this.

I'd expect either correct results to be returned, or an exception to be raised, 
but in this case, and the docs for wait_for ( 
https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for ), I'd 
expect the correct results to be returned.


In the attached case, this is the results that I get:
$python3.7 asyncitertc.py 
3.7.5 (default, Oct 18 2019, 23:59:39) 
[Clang 7.0.2 (clang-700.1.81)]
timed out
yielding 1
results: None
getting 2: 2

I do not have python 3.8 to test with.

--
files: asyncitertc.py
messages: 360254
nosy: jmg
priority: normal
severity: normal
status: open
title: getting invalid data from async iterator
Added file: https://bugs.python.org/file48852/asyncitertc.py

___
Python tracker 

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