fluentpython / example-code-2e

Example code for Fluent Python, 2nd edition (O'Reilly 2022)
https://amzn.to/3J48u2J
MIT License
3.26k stars 919 forks source link

Bug in flags2_asyncio.py (and flags3_asyncio.py) reporting #32

Open jgc31 opened 1 year ago

jgc31 commented 1 year ago

First, let me thank you very much for this great book! Fluent Python is very pedagogical, informative and quite a pleasure to read.

So, I have been quite surprised to encounter a bug when running flags2_asyncio.py, in the error accounting in the supervisor function. After a first error happens, all downloads are counted as erroneous, even when they are in fact successful. This is because the "error" variable is never reset after entering the for loop. This can be fixed simply by adding "else: error = None" at the end of the try/except (parallel to what you do in flags2_threadpool.py and flags2_asyncio_executor.py).

This bug is also present in flags3_asyncio.py.

(I am using Python3.10.)

A big thank you again!