[issue29432] wait_for(gather(...)) logs weird error message

2017-08-07 Thread Chris Jerdonek

Chris Jerdonek added the comment:

By the way, I see this exact issue was also raised and discussed here, with a 
couple responses by Guido, too:
https://github.com/python/asyncio/issues/253

--

___
Python tracker 

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



[issue29432] wait_for(gather(...)) logs weird error message

2017-08-07 Thread Chris Jerdonek

Chris Jerdonek added the comment:

I noticed that the future defined by asyncio.gather(sleep) is in a "pending" 
state immediately after the asyncio.TimeoutError.

One workaround is to wait for the cancellation to finish:

@asyncio.coroutine
def main():
sleep = asyncio.sleep(0.2)
future = asyncio.gather(sleep)
try:
yield from asyncio.wait_for(future, timeout=0.1)
except asyncio.TimeoutError:
print(f'future: {future}')
try:
yield from future
except asyncio.CancelledError:
print(f'future: {future}')
yield from asyncio.sleep(0.1)

asyncio.get_event_loop().run_until_complete(main())

Outputs:

future: <_GatheringFuture pending>
future: <_GatheringFuture finished exception=CancelledError()>

Another option is to pass return_exceptions=True to gather(). This appears to 
make the log messages you were concerned about go away:

future: <_GatheringFuture pending>

--
nosy: +chris.jerdonek

___
Python tracker 

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



[issue29432] wait_for(gather(...)) logs weird error message

2017-02-08 Thread Martin Teichmann

Martin Teichmann added the comment:

I added a solution to this problem. I just silence the bad error message by 
overwriting _GatheringFuture.__del__ to do nothing. This may have undesired 
side effects, though.

--

___
Python tracker 

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



[issue29432] wait_for(gather(...)) logs weird error message

2017-02-03 Thread Martin Teichmann

New submission from Martin Teichmann:

when waiting for a gather that times out, everything works as expected, yet a 
weird error message is logged. To give a minimal example:

import asyncio

@asyncio.coroutine
def main():
try:
sleep = asyncio.sleep(0.2)
yield from asyncio.wait_for(asyncio.gather(sleep),
timeout=0.1)
except asyncio.TimeoutError:
print("timed out: fine")
yield from asyncio.sleep(0.1)

asyncio.get_event_loop().run_until_complete(main())

This outputs:

timed out: fine
_GatheringFuture exception was never retrieved
future: <_GatheringFuture finished exception=CancelledError()>
concurrent.futures._base.CancelledError

As you can see, I used the pre-3.5 syntax so I could test whether it works on 
older systems. No, it doesn't.

I wrote a unit test for this problem, unfortunately I couldn't solve it yet.

--
components: asyncio
messages: 286858
nosy: Martin.Teichmann, gvanrossum, yselivanov
priority: normal
pull_requests: 24
severity: normal
status: open
title: wait_for(gather(...)) logs weird error message
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue29432] wait_for(gather(...)) logs weird error message

2017-02-03 Thread Martin Teichmann

Changes by Martin Teichmann :


--
type:  -> behavior

___
Python tracker 

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