lib: add bt_{graph,query_executor}_add_interrupter()
[babeltrace.git] / src / bindings / python / bt2 / bt2 / component.py
index ef86bbcf50f1f42028e4789208e6222c6e90601b..43e3ce1645bb90fe4c4a80f9e4b853ea70640af1 100644 (file)
@@ -481,13 +481,6 @@ class _UserComponentType(type):
                 cls, comp_cls_name, comp_cls_descr, comp_cls_help
             )
         elif _UserSinkComponent in bases:
-            if not hasattr(cls, '_graph_is_configured'):
-                raise bt2.IncompleteUserClass(
-                    "cannot create component class '{}': missing a _graph_is_configured() method".format(
-                        class_name
-                    )
-                )
-
             if not hasattr(cls, '_consume'):
                 raise bt2.IncompleteUserClass(
                     "cannot create component class '{}': missing a _consume() method".format(
@@ -506,7 +499,7 @@ class _UserComponentType(type):
             )
 
         if cc_ptr is None:
-            raise bt2.CreationError(
+            raise bt2._MemoryError(
                 "cannot create component class '{}'".format(class_name)
             )
 
@@ -529,7 +522,7 @@ class _UserComponentType(type):
         return self
 
     def __call__(cls, *args, **kwargs):
-        raise bt2.Error(
+        raise RuntimeError(
             'cannot directly instantiate a user component from a Python module'
         )
 
@@ -679,15 +672,12 @@ class _UserComponent(metaclass=_UserComponentType):
         )
         self._port_connected(port, other_port)
 
-    def _bt_graph_is_configured_from_native(self):
-        self._graph_is_configured()
-
     def _create_trace_class(self, assigns_automatic_stream_class_id=True):
         ptr = self._bt_as_self_component_ptr(self._bt_ptr)
         tc_ptr = native_bt.trace_class_create(ptr)
 
         if tc_ptr is None:
-            raise bt2.CreationError('could not create trace class')
+            raise bt2._MemoryError('could not create trace class')
 
         tc = bt2._TraceClass._create_from_ptr(tc_ptr)
         tc._assigns_automatic_stream_class_id = assigns_automatic_stream_class_id
@@ -708,7 +698,7 @@ class _UserComponent(metaclass=_UserComponentType):
         cc_ptr = native_bt.clock_class_create(ptr)
 
         if cc_ptr is None:
-            raise bt2.CreationError('could not create clock class')
+            raise bt2._MemoryError('could not create clock class')
 
         cc = bt2.clock_class._ClockClass._create_from_ptr(cc_ptr)
 
@@ -833,6 +823,12 @@ class _UserSinkComponent(_UserComponent, _SinkComponent):
         native_bt.self_component_sink_as_self_component
     )
 
+    def _bt_graph_is_configured_from_native(self):
+        self._graph_is_configured()
+
+    def _graph_is_configured(self):
+        pass
+
     @property
     def _input_ports(self):
         def get_input_port_count(self_ptr):
@@ -856,3 +852,19 @@ class _UserSinkComponent(_UserComponent, _SinkComponent):
         )
         assert self_port_ptr
         return bt2.port._UserComponentInputPort._create_from_ptr(self_port_ptr)
+
+    def _create_input_port_message_iterator(self, input_port):
+        utils._check_type(input_port, bt2.port._UserComponentInputPort)
+
+        msg_iter_ptr = native_bt.self_component_port_input_message_iterator_create_from_sink_component(
+            self._bt_ptr, input_port._ptr
+        )
+
+        if msg_iter_ptr is None:
+            raise bt2.CreationError('cannot create message iterator object')
+
+        return bt2.message_iterator._UserComponentInputPortMessageIterator(msg_iter_ptr)
+
+    @property
+    def _is_interrupted(self):
+        return bool(native_bt.self_component_sink_is_interrupted(self._bt_ptr))
This page took 0.031763 seconds and 4 git commands to generate.