pause_gc

function of dascore.utils.remote_io source

pause_gc()-> ‘None’

Pause automatic garbage collection for one remote read session.

h5py holds its process-global lock while blocking on fsspec’s event-loop thread for each remote fetch. An automatic collection on that thread which has to deallocate a dead h5py object needs the same lock, so the two threads deadlock. Disabling automatic collection for the handle’s lifetime closes that window; reference counting still frees non-cyclic garbage.

h5py documents this deadlock, and disabling collection as one of its two mitigations, under “Python file-like objects”: https://docs.h5py.org/en/stable/high/file.html#python-file-like-objects Its other mitigation, avoiding reference cycles which keep h5py objects alive, is not available to us: the cycle can be anywhere in the process.

Calls nest; every pause_gc needs one resume_gc. _ManagedH5pyFile pairs them with close/__del__. An interrupted pause_gc still leaves the depth consistent with the pauses it took, so a caller which resumes on any failure stays balanced.

The pause is process-global, so cyclic garbage from every thread accumulates until the last remote handle closes. A handle which is never closed keeps it paused; one which is dropped inside a reference cycle is recovered by the collection below, on the next remote open – if the program makes one. Otherwise the pause outlives every remote read.