Fix: src.ctf.fs: initialize the other_entry variable
[babeltrace.git] / src / bindings / python / bt2 / bt2 / graph.py
index b1d59700c8cc100c50d3c28809d82edf7495cf04..9611c6e287b9f7f69c8a1560317c5d75a56848f0 100644 (file)
@@ -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,
@@ -115,7 +119,9 @@ class Graph(object._SharedObject):
         )
         utils._handle_func_status(status, 'cannot add component to graph')
         assert comp_ptr
-        return bt2_component._create_component_from_const_ptr(comp_ptr, cc_type)
+        return bt2_component._create_component_from_const_ptr_and_get_ref(
+            comp_ptr, cc_type
+        )
 
     def connect_ports(self, upstream_port, downstream_port):
         utils._check_type(upstream_port, bt2_port._OutputPortConst)
@@ -125,7 +131,7 @@ class Graph(object._SharedObject):
         )
         utils._handle_func_status(status, 'cannot connect component ports within graph')
         assert conn_ptr
-        return bt2_connection._ConnectionConst._create_from_ptr(conn_ptr)
+        return bt2_connection._ConnectionConst._create_from_ptr_and_get_ref(conn_ptr)
 
     def add_port_added_listener(self, listener):
         if not callable(listener):
@@ -140,6 +146,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')
@@ -152,5 +161,7 @@ class Graph(object._SharedObject):
         utils._check_type(interrupter, bt2_interrupter.Interrupter)
         native_bt.graph_add_interrupter(self._ptr, interrupter._ptr)
 
-    def interrupt(self):
-        native_bt.graph_interrupt(self._ptr)
+    @property
+    def default_interrupter(self):
+        ptr = native_bt.graph_borrow_default_interrupter(self._ptr)
+        return bt2_interrupter.Interrupter._create_from_ptr_and_get_ref(ptr)
This page took 0.026844 seconds and 4 git commands to generate.