An exception is being thrown when objects that use `CapturableResourceDeleter` are garbage collected at the end of a program's life. This can happen in very normal circumstances, such as when using `saved_model_cli` to inspect a model. The cause of the exception appears to be a race condition with garbage collection between `CapturableResourceDeleter` and `ScopedTFFunction`. Both define a custom finalizer (`__del__`); `CaptureableResourceDeleter`'s finalizer ultimately calls a concrete function which calls an `_EagerDefinedFunction` which attempts to load and execute a `ScopedTFFunction`. In the case of multiple objects in a reference cycle all going unreachable during the same garbage collection cycle, we get no guaranteed ordering for which of the objects will be collected first. In the case of the exception, `ScopedTFFunction` is collected first and its underlying function is deleted. Later, `CapturableResourceDeleter` is called, which fails, since the function it's trying to call is gone. PiperOrigin-RevId: 358292164 Change-Id: I9162d5de622f5c1ec9b2954647b9958a7d3d87b6 |
||
---|---|---|
.. | ||
base_test.py | ||
base.py | ||
benchmarks_test.py | ||
BUILD | ||
data_structures_test.py | ||
data_structures.py | ||
graph_view.py | ||
layer_utils.py | ||
python_state_test.py | ||
python_state.py | ||
tracking_test.py | ||
tracking.py | ||
util_test.py | ||
util_with_v1_optimizers_test.py | ||
util.py |