pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.48k stars 525 forks source link

Catch `BaseException` instead of `Exception` #641

Closed aleneum closed 1 month ago

aleneum commented 8 months ago

Exception is not broad enough and does not catch asyncio.CancelledError or KeyboardInterrupt. transitions will exclusively catch BaseException from now on.

This has to major implications: First on_exception is not called when a task is cancelled. This will happen when an asynchronous event cancels currently running callbacks or a KeyboardInterrupt is called. Second, when queue=True CancelledError will not cause the queue to get cleared and render the machine unusable from thereon.

codecov[bot] commented 8 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (8ab2529) 98.40% compared to head (4c7ae1f) 98.40%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #641 +/- ## ======================================= Coverage 98.40% 98.40% ======================================= Files 13 13 Lines 2573 2573 ======================================= Hits 2532 2532 Misses 41 41 ``` | [Files](https://app.codecov.io/gh/pytransitions/transitions/pull/641?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytransitions) | Coverage Δ | | |---|---|---| | [transitions/core.py](https://app.codecov.io/gh/pytransitions/transitions/pull/641?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytransitions#diff-dHJhbnNpdGlvbnMvY29yZS5weQ==) | `100.00% <100.00%> (ø)` | | | [transitions/extensions/nesting.py](https://app.codecov.io/gh/pytransitions/transitions/pull/641?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytransitions#diff-dHJhbnNpdGlvbnMvZXh0ZW5zaW9ucy9uZXN0aW5nLnB5) | `99.29% <100.00%> (ø)` | | | [transitions/extensions/asyncio.py](https://app.codecov.io/gh/pytransitions/transitions/pull/641?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytransitions#diff-dHJhbnNpdGlvbnMvZXh0ZW5zaW9ucy9hc3luY2lvLnB5) | `97.77% <75.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.