bt2: remove BT CC entry from global HT in _UserComponentType.__del__()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 3 Aug 2019 18:29:27 +0000 (14:29 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 5 Aug 2019 19:10:13 +0000 (15:10 -0400)
commitab1cea3f45de3ad0f4d70165c723f321a0eae10c
tree4ee5dad0ec280c17341974c597dddaafae12d804
parent45bab74488ace74075d90fea7f776a19906aec05
bt2: remove BT CC entry from global HT in _UserComponentType.__del__()

The global `bt_cc_ptr_to_py_cls` hash table maps BT component class
pointers to Python component classes (`PyObject *`) for component
classes created in Python. The key and value are weak references.

When the Python side calls native_bt.bt2_component_class_*_create() with
a Python component class, an entry is added to `bt_cc_ptr_to_py_cls` on
success. This works most of the time because all Python classes are
normally destroyed when the interpreter is finalized, but there could be
issues with specific/unusual import patterns.

To avoid potential issues, remove an entry from `bt_cc_ptr_to_py_cls` in
_UserComponentType.__del__(), where a strong BT component class
reference is finally released.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I450a1c6f179f352e758b9e3e5cac8f4711aa3c88
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1816
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/native_bt_component_class.i
src/bindings/python/bt2/bt2/native_bt_component_class.i.h
This page took 0.025208 seconds and 4 git commands to generate.