Grokking Concurrency in Python
Vote

0% completed

​

Async Iterators, Generators and Context Managers

An ordinary generator and an async generator can do the same job: open a connection, hand out a page piece by piece, and close the connection in a finally block. A consumer that needs only the start of the page takes one piece and leaves its loop with break. When the consumer drops an ordinary generator, CPython closes it at once. When it drops an async generator, the finally block runs later, at a moment the consumer does not control.

In Harvest, that difference kept a connection to the test site open after the loop had finished with it

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content