Grokking Concurrency in Python
0% completed
Writing Cancellation-Safe Code
crawl.visited.add(n) page = await fetch_unsafe(n) counts = index(page) await crawl.store.put_doc(n, len(page.split())) await crawl.store.put_postings(n, counts)
Each of these lines from Harvest's fetch-and-store step is correct on its own. The damage comes from where the step can stop. A cancellation can end the step at any await, and each await leaves different damage: a page marked as visited but never stored, a record that is only half written, or a connection that is never closed.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%