torchcell.loader.cpu_experiment_loader.CpuExperimentLoaderMultiprocessing
- class CpuExperimentLoaderMultiprocessing(dataset: Sequence[Any], batch_size: int, num_workers: int)[source]
Bases:
objectProcess-based loader that prefetches dataset batches into a queue.
- static worker_function(load_queue: Queue[int | None], data_queue: Queue[list[Any]], dataset: Sequence[Any], batch_size: int) None[source]
Pull batch indices, slice the dataset, and push batches until stopped.
- close() None[source]
Tear down workers once (idempotent); never block indefinitely.
On the normal path workers are parked on
load_queue.get()and exit on theNonesentinel. On an error path the consumer may have abandoned iteration withdata_queuefull and workers blocked onput– those never reach the sentinel, so a plainjoin()would hang forever. We draindata_queueto unblock them within a bounded budget, then force-terminate any straggler soclose()itself can never deadlock.