Repository navigation
Adapt to Task.cancel now being deprecated. - #490
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
eb9af88 to
346fb4a
Compare
| requires-python = ">=3.8" | ||
| dependencies = [ | ||
| "ewokscore >=5", | ||
| "ewokscore >=5.1.0rc5", |
There was a problem hiding this comment.
We could keep version 5 compatibility but this is a bit cumbersome for the inheritance. So I moved forward. Let me know if there is reason to keep compatibly with version 5.0
346fb4a to
98e02e9
Compare
…ore>=5.1.0rc5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # pyproject.toml
… (ewokscore#514) Task.abort was finally renamed to Task.request_stop, which sets the `stop_requested` flag and calls the `_on_stop_requested` hook that tasks should implement. `stop_requested` is now unambiguously the request (no setter), so the "request vs state" interpretations of `cancelled` are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b8f12e8 to
628e0ec
Compare
| class StateCancelTask( | ||
| class InterruptCancelTask( |
There was a problem hiding this comment.
Renamed for clarity. I haven't saw any project using it but still breaking the public API.
| step = 0.05 | ||
| elapsed = 0.0 | ||
| while elapsed < self.inputs.duration: | ||
| if self.__cancel_requested: | ||
| self.cancelled = True | ||
| return | ||
| time.sleep(step) | ||
| elapsed += step | ||
| self.outputs.result = f"slept {elapsed:.2f}s" | ||
| if self.__stop_event.wait(timeout=self.inputs.duration): | ||
| return | ||
| self.outputs.result = f"slept {self.inputs.duration:.2f}s" | ||
|
|
||
| def cancel(self): | ||
| """Interpretation #1: self.cancelled is the state not the request.""" | ||
| self.__cancel_requested = True | ||
| def _on_stop_requested(self): | ||
| self.__stop_event.set() |
There was a problem hiding this comment.
Simplification of the cancellation.
The origin of the modification is that stop_requested (replacing cancelled) has no more setter. It is set directly when stop_requested is called. Which makes it more robust and clarify the states.
This is more 'strict' this way for the best.
There was a problem hiding this comment.
I will do a follow-up in #501 which re-introduces abort but then real aborting.
PR summary
Adapt code to use
Taskabortfunction instead ofcancel.Note
Related to ewoks-kit/ewokscore#514
AI Disclosure