DiamondLightSource / DiamondLightSource/httomo
Fix `StandardTomoLoader` not being garbage collected until program termination
- Dominant language
- Python
- Stars
- 10
- Forks
- 5
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 1
Description
`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 to `weakref.finalize()`
https://github.com/DiamondLightSource/httomo/blob/fcc94798384244b01c5dbef231cfe30e00adda70/httomo/loaders/standard_tomo_loader.py#L80
However, there is also another issue:
- the `TaskRunner` keeps a reference to the `Pipeline` object for the _entire_ pipeline execution
https://github.com/DiamondLightSource/httomo/blob/fcc94798384244b01c5dbef231cfe30e00adda70/httomo/runner/task_runner.py#L31-L33
- the `Pipeline` object keeps a reference to an instance of the relevant loader (which is always `StandardTomoLoader` for the moment)
https://github.com/DiamondLightSource/httomo/blob/fcc94798384244b01c5dbef231cfe30e00adda70/httomo/runner/pipeline.py#L12-L18
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`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.