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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 7 Aug 2019 18:05:20 +0000 (14:05 -0400)
commit774b7f288e268259639df192409a348c32d1f57a
tree1e2097ae114f146beb2a7917e00e1110281cfcc5
parent821b04aaf8b4aaf0035400707d425bfa2f7933b0
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.025067 seconds and 4 git commands to generate.