asyncio does not always show the full traceback

Frank Millman frank at chagford.com
Thu Mar 2 07:55:46 EST 2017


"INADA Naoki"  wrote in message 
news:CAEfz+TyUdWJesyttqZg2_ROMPhmJRxqaGA2ULgFQV5QbpiiiXQ at mail.gmail.com...
>
> I can't reproduce it on Linux.
> Maybe, it's windows specific bug?
>

> import asyncio
> from itertools import count
>
> async def aenumerate(aiterable):
>    counter = count()
>    async for x in aiterable:
>        yield next(counter), x
>        await asyncio.sleep(0.5)
>
> async def gen(n):
>    for i in range(100, 100+n):
>        yield i
>
> async def aenum():
>    g = gen(5)
>    async for a, x in aenumerate(g):
>        print(a, x)
>    print('done')
>
> async def main():
>    await aenum()
>
> loop = asyncio.get_event_loop()
> loop.run_until_complete(main())
>

Thanks for the reply.

I tried it out on linux (Fedora 22, Python 3.6.0b4), and I get the same 
result as I do on Windows.

If I place '1/0' in main(), this is the traceback -

Traceback (most recent call last):
  File "test_db1a.py", line 25, in <module>
    loop.run_until_complete(main())
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 466, in 
run_until_complete
    return future.result()
ZeroDivisionError: division by zero

If I place '1/0' in gen(), this is the traceback -

Traceback (most recent call last):
  File "test_db1a.py", line 25, in <module>
    loop.run_until_complete(main())
  File "/usr/local/lib/python3.6/asyncio\base_events.py", line 466, in 
run_until_complete
    return future.result()
  File "test_db1a.py", line 17, in aenum
    async for a, x in aenumerate(g):
  File "test_db1a.py", line 6, in aenumerate
    async for x in aiterable:
  File "test_db1a.py", line 11, in gen
    1/0
ZeroDivisionError: division by zero

Can anyone else confirm whether they can reproduce my results?

Thanks

Frank




More information about the Python-list mailing list