Skip to content

Adapt to Task.cancel now being deprecated. - #490

Open
payno wants to merge 4 commits into
mainfrom
rename_task_cancel_to_abort
Open

payno wants to merge 4 commits into
mainfrom
rename_task_cancel_to_abort

Conversation

@payno

@payno payno commented Oct 7, 2026

Copy link
Copy Markdown
Member

PR summary

Adapt code to use Task abort function instead of cancel.

Note

Related to ewoks-kit/ewokscore#514

AI Disclosure

  • Claude used

@payno payno linked an issue Oct 7, 2026 that may be closed by this pull request
@payno payno changed the title Adapt to Task.cancel now being deprecated. DRAFT: Adapt to Task.cancel now being deprecated. Oct 7, 2026
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...rc/ewoksorange/gui/concurrency/_runners/process.py 0.00% 1 Missing ⚠️
src/ewoksorange/gui/concurrency/threaded.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@payno
payno force-pushed the rename_task_cancel_to_abort branch from eb9af88 to 346fb4a Compare October 7, 2026 07:39
Comment thread pyproject.toml
requires-python = ">=3.8"
dependencies = [
"ewokscore >=5",
"ewokscore >=5.1.0rc5",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

payno and others added 3 commits October 13, 2026 13:53
…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>
@payno
payno force-pushed the rename_task_cancel_to_abort branch from b8f12e8 to 628e0ec Compare October 13, 2026 11:54
Comment on lines -108 to +109
class StateCancelTask(
class InterruptCancelTask(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed for clarity. I haven't saw any project using it but still breaking the public API.

Comment on lines -121 to +127
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()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@payno payno changed the title DRAFT: Adapt to Task.cancel now being deprecated. Adapt to Task.cancel now being deprecated. Oct 13, 2026
@payno
payno requested a review from a team October 13, 2026 12:33

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OWEwoksWidgetWithTaskStack: provide API to cancel a task

1 participant