- listener_id = fn(self._ptr, listener_from_native)
- utils._handle_ret(listener_id, 'cannot add listener to graph object')
- return bt2._ListenerHandle(listener_id, self)
+ listener_ids = fn(self._ptr, listener_from_native)
+ if listener_ids is None:
+ utils._raise_bt2_error('cannot add listener to graph object')
+ return bt2._ListenerHandle(listener_ids, self)
+
+ def add_ports_connected_listener(self, listener):
+ if not callable(listener):
+ raise TypeError("'listener' parameter is not callable")
+
+ fn = native_bt.py3_graph_add_ports_connected_listener
+ listener_from_native = functools.partial(_graph_ports_connected_listener_from_native,
+ listener)
+
+ listener_ids = fn(self._ptr, listener_from_native)
+ if listener_ids is None:
+ utils._raise_bt2_error('cannot add listener to graph object')
+ return bt2._ListenerHandle(listener_ids, self)