X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fgraph.py;h=a3926e5951ff14df902f47c5b5203281bad27cbd;hp=b1d59700c8cc100c50d3c28809d82edf7495cf04;hb=f3d6b4c2f7592fde9ff770989b25bacaa4820dc8;hpb=2945edfe752782d2528af21bdbd3bbfef4cd51ca diff --git a/src/bindings/python/bt2/bt2/graph.py b/src/bindings/python/bt2/bt2/graph.py index b1d59700..a3926e59 100644 --- a/src/bindings/python/bt2/bt2/graph.py +++ b/src/bindings/python/bt2/bt2/graph.py @@ -57,6 +57,10 @@ class Graph(object._SharedObject): super().__init__(ptr) + # list of listener partials to keep a reference as long as + # this graph exists + self._listener_partials = [] + def add_component( self, component_class, @@ -140,6 +144,9 @@ class Graph(object._SharedObject): if listener_ids is None: raise bt2._Error('cannot add listener to graph object') + # keep the partial's reference + self._listener_partials.append(listener_from_native) + def run_once(self): status = native_bt.graph_run_once(self._ptr) utils._handle_func_status(status, 'graph object could not run once')