Quick way to set 3D dataset at handler to None to release memory.
()
| 4086 | |
| 4087 | # TODO: the following function may be deleted after Databroker 0.13 is forgotten |
| 4088 | def free_memory_from_handler(): |
| 4089 | """ |
| 4090 | Quick way to set 3D dataset at handler to None to release memory. |
| 4091 | """ |
| 4092 | # The following check is redundant: Data Broker prior to version 1.0.0 always has '_handler_cache'. |
| 4093 | # In later versions of databroker the attribute may still be present if 'databroker.v0' is used. |
| 4094 | if ( |
| 4095 | (LooseVersion(databroker.__version__) < LooseVersion("1.0.0")) |
| 4096 | or hasattr(db, "fs") |
| 4097 | and hasattr(db.fs, "_handler_cache") |
| 4098 | ): |
| 4099 | for h in db.fs._handler_cache.values(): |
| 4100 | setattr(h, "_dataset", None) |
| 4101 | print("Memory is released (Databroker v0).") |
| 4102 | elif hasattr(db, "_catalog") and hasattr(db._catalog, "_entries"): |
| 4103 | db._catalog._entries.cache_clear() |
| 4104 | print("Memory is released (Databroker v1).") |
| 4105 | |
| 4106 | |
| 4107 | def export1d(runid, name=None): |
no test coverage detected