Hence, the loader object's reference count will never drop to 0 during pipeline execution, and will only get garbage collected upon program termination.
Therefore, even if the same fix for #264 is applied here to use weakref.WeakMethod, we still need to change things to somehow make the reference count of the loader object drop to 0 when we no longer need it, while still keeping a reference to the instance of Pipeline in TaskRunner.
StandardTomoLoader
suffers the same issue detailed in #264: it won't be garbage collected until program termination due to a reference to a bound method being given toweakref.finalize()
https://github.com/DiamondLightSource/httomo/blob/fcc94798384244b01c5dbef231cfe30e00adda70/httomo/loaders/standard_tomo_loader.py#L80However, there is also another issue:
TaskRunner
keeps a reference to thePipeline
object for the entire pipeline execution https://github.com/DiamondLightSource/httomo/blob/fcc94798384244b01c5dbef231cfe30e00adda70/httomo/runner/task_runner.py#L31-L33Pipeline
object keeps a reference to an instance of the relevant loader (which is alwaysStandardTomoLoader
for the moment) https://github.com/DiamondLightSource/httomo/blob/fcc94798384244b01c5dbef231cfe30e00adda70/httomo/runner/pipeline.py#L12-L18Hence, the loader object's reference count will never drop to 0 during pipeline execution, and will only get garbage collected upon program termination.
Therefore, even if the same fix for #264 is applied here to use
weakref.WeakMethod
, we still need to change things to somehow make the reference count of the loader object drop to 0 when we no longer need it, while still keeping a reference to the instance ofPipeline
inTaskRunner
.