"INADA Naoki" wrote in message
news:caefz+tyudwjesyttqzg2_romphmjrxqaga2ulgfqv5qbpii...@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
--
https://mail.python.org/mailman/listinfo/python-list