from contextlib import closing
import dascore as dc
spool = dc.get_example_spool()
with closing(spool.iterate(max_in_flight=2)) as patches:
for patch in patches:
result = patch.abs()iterate
iterate(
self ,
max_in_flight: int = 2,
)-> ‘Generator[dc.Patch, None, None]’
Yield patches in order while a background thread loads ahead.
Parameters
| Parameter | Description |
|---|---|
| max_in_flight |
Maximum number of upcoming patches being loaded or buffered. The patch already yielded to the caller is additional. Set to zero to iterate in the calling thread without prefetching. |
Loading starts when iteration begins. Selection, chunking, inventory enrichment, and skipping unresolvable patches follow ordinary spool iteration. The loading thread uses the DASCore configuration active when this method was called. Ordinary for patch in spool stays synchronous. A positive window requires thread support; on WebAssembly, use ordinary iteration or explicitly set max_in_flight=0. A zero window uses the configuration active when each patch is consumed, just like ordinary iteration. Threaded directory iteration requires a serialized SQLite build (sqlite3.threadsafety == 3).
The limit counts patches, not bytes, and does not include patches the caller retains. Close the iterator when stopping early: pending reads are cancelled and any running read finishes before its thread exits.