diff --git a/transitions/core.py b/transitions/core.py index 8b42d553..1c6c5786 100644 --- a/transitions/core.py +++ b/transitions/core.py @@ -414,7 +414,7 @@ def _trigger(self, event_data): try: if self._is_valid_source(event_data.state): self._process(event_data) - except Exception as err: # pylint: disable=broad-except; Exception will be handled elsewhere + except BaseException as err: # pylint: disable=broad-except; Exception will be handled elsewhere event_data.error = err if self.machine.on_exception: self.machine.callbacks(self.machine.on_exception, event_data) @@ -424,7 +424,7 @@ def _trigger(self, event_data): try: self.machine.callbacks(self.machine.finalize_event, event_data) _LOGGER.debug("%sExecuted machine finalize callbacks", self.machine.name) - except Exception as err: # pylint: disable=broad-except; Exception will be handled elsewhere + except BaseException as err: # pylint: disable=broad-except; Exception will be handled elsewhere _LOGGER.error("%sWhile executing finalize callbacks a %s occurred: %s.", self.machine.name, type(err).__name__, @@ -1224,7 +1224,7 @@ def _process(self, trigger): try: self._transition_queue[0]() self._transition_queue.popleft() - except Exception: + except BaseException: # if a transition raises an exception, clear queue and delegate exception handling self._transition_queue.clear() raise diff --git a/transitions/extensions/asyncio.py b/transitions/extensions/asyncio.py index dd3faf5f..09ec963f 100644 --- a/transitions/extensions/asyncio.py +++ b/transitions/extensions/asyncio.py @@ -181,7 +181,7 @@ async def _trigger(self, event_data): try: if self._is_valid_source(event_data.state): await self._process(event_data) - except Exception as err: # pylint: disable=broad-except; Exception will be handled elsewhere + except BaseException as err: # pylint: disable=broad-except; Exception will be handled elsewhere _LOGGER.error("%sException was raised while processing the trigger: %s", self.machine.name, err) event_data.error = err if self.machine.on_exception: @@ -455,7 +455,7 @@ async def _process_async(self, trigger, model): while self._transition_queue_dict[id(model)]: try: await self._transition_queue_dict[id(model)][0]() - except Exception: + except BaseException: # if a transition raises an exception, clear queue and delegate exception handling self._transition_queue_dict[id(model)].clear() raise @@ -503,7 +503,7 @@ async def _trigger_event(self, event_data, trigger): with self(): res = await self._trigger_event_nested(event_data, trigger, None) event_data.result = self._check_event_result(res, event_data.model, trigger) - except Exception as err: # pylint: disable=broad-except; Exception will be handled elsewhere + except BaseException as err: # pylint: disable=broad-except; Exception will be handled elsewhere event_data.error = err if self.on_exception: await self.callbacks(self.on_exception, event_data) @@ -513,7 +513,7 @@ async def _trigger_event(self, event_data, trigger): try: await self.callbacks(self.finalize_event, event_data) _LOGGER.debug("%sExecuted machine finalize callbacks", self.name) - except Exception as err: # pylint: disable=broad-except; Exception will be handled elsewhere + except BaseException as err: # pylint: disable=broad-except; Exception will be handled elsewhere _LOGGER.error("%sWhile executing finalize callbacks a %s occurred: %s.", self.name, type(err).__name__, diff --git a/transitions/extensions/nesting.py b/transitions/extensions/nesting.py index d8c54ef7..9c759453 100644 --- a/transitions/extensions/nesting.py +++ b/transitions/extensions/nesting.py @@ -812,7 +812,7 @@ def _trigger_event(self, event_data, trigger): with self(): res = self._trigger_event_nested(event_data, trigger, None) event_data.result = self._check_event_result(res, event_data.model, trigger) - except Exception as err: # pylint: disable=broad-except; Exception will be handled elsewhere + except BaseException as err: # pylint: disable=broad-except; Exception will be handled elsewhere event_data.error = err if self.on_exception: self.callbacks(self.on_exception, event_data) @@ -822,7 +822,7 @@ def _trigger_event(self, event_data, trigger): try: self.callbacks(self.finalize_event, event_data) _LOGGER.debug("%sExecuted machine finalize callbacks", self.name) - except Exception as err: # pylint: disable=broad-except; Exception will be handled elsewhere + except BaseException as err: # pylint: disable=broad-except; Exception will be handled elsewhere _LOGGER.error("%sWhile executing finalize callbacks a %s occurred: %s.", self.name, type(err).__name__,