# THE SOFTWARE.
from bt2 import native_bt, object, utils
-import bt2.component
-import bt2.logging
+from bt2 import interrupter as bt2_interrupter
+from bt2 import component as bt2_component
+from bt2 import logging as bt2_logging
+from bt2 import value as bt2_value
import bt2
super().__init__(ptr)
- def cancel(self):
- status = native_bt.query_executor_cancel(self._ptr)
- utils._handle_func_status(status, 'cannot cancel query executor object')
+ def add_interrupter(self, interrupter):
+ utils._check_type(interrupter, bt2_interrupter.Interrupter)
+ native_bt.query_executor_add_interrupter(self._ptr, interrupter._ptr)
+
+ def interrupt(self):
+ native_bt.query_executor_interrupt(self._ptr)
@property
- def is_canceled(self):
- is_canceled = native_bt.query_executor_is_canceled(self._ptr)
- assert is_canceled >= 0
- return is_canceled > 0
+ def is_interrupted(self):
+ is_interrupted = native_bt.query_executor_is_interrupted(self._ptr)
+ return bool(is_interrupted)
def query(
self,
component_class,
object,
params=None,
- logging_level=bt2.logging.LoggingLevel.NONE,
+ logging_level=bt2_logging.LoggingLevel.NONE,
):
- if self.is_canceled:
- raise bt2.Canceled
-
- if not isinstance(component_class, bt2.component._GenericComponentClass):
+ if not isinstance(component_class, bt2_component._ComponentClass):
err = False
try:
- if not issubclass(component_class, bt2.component._UserComponent):
+ if not issubclass(component_class, bt2_component._UserComponent):
err = True
except TypeError:
err = True
)
utils._handle_func_status(status, 'cannot query component class')
assert result_ptr
- return bt2.value._create_from_ptr(result_ptr)
+ return bt2_value._create_from_ptr(result_ptr)