Why does asyncio.wait_for() need a timeout?

Frank Millman frank at chagford.com
Fri Nov 24 08:31:46 EST 2017


"Frank Millman"  wrote in message news:ov5v3s$bv7$1 at blaine.gmane.org...

> Below is a simple asyncio loop that runs two background tasks.
>
[...]
>
> Both take an optional timeout.
>
> If I use the first method without a timeout, the cancellation completes 
> and the loop stops.
>
> If I use the second method without a timeout, the future is cancelled, but 
> the program hangs.
>
> If I add a timeout to the second one, it behaves the same as the first 
> one.
>
> Is there a reason for this?
>

I have figured out half of the answer.

'timeout' is an optional argument when using wait(), but a required one when 
using wait_for().

Therefore asyncio is raising an exception.

However, I do not understand why no traceback appears.

Frank






More information about the Python-list mailing list