16/28
Part 5 of 6 · Errors and shared stateLearn and do

One bad page is a log line

Real pages fail: a server refuses, or a connection drops. One failure must not stop the crawl.

result() raises the fetch's error in the thread that asks for it

with ThreadPoolExecutor(max_workers=2) as pool:
    future = pool.submit(fetch, f"{E}/broken")
    try:
        future.result()
    except ConnectionError as exc:
        print("result() raised", repr(exc))
Predict

The fetch of /broken raises ConnectionError on a worker thread. What happens when the main thread calls future.result()?

Pick one to see what it prints.
Pick an answer above to see the rest