Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close cancelled coroutine #1394

Conversation

nadavelkabets
Copy link
Contributor

@nadavelkabets nadavelkabets commented Jan 4, 2025

Fixed the issue in PR #1377 where cancelled coroutines are not closed and implemented a FutureState similar to asyncio.
The failed test is now passing.

@nadavelkabets nadavelkabets force-pushed the nadavelkabets/close-cancelled-coroutine branch from 057ec92 to abc12b1 Compare January 4, 2025 20:26
Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>
Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>
Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>
@nadavelkabets nadavelkabets force-pushed the nadavelkabets/close-cancelled-coroutine branch from abc12b1 to c52e58d Compare January 4, 2025 20:27
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

@nadavelkabets really appreciate your effort with detailed description, lgtm.

@fujitatomoya fujitatomoya merged commit 38e5ebb into ros2:fujitatomoya/check-task-canceled Jan 5, 2025
2 checks passed
fujitatomoya pushed a commit that referenced this pull request Jan 5, 2025
* Add FutureState

Signed-off-by: Nadav Elkabets <[email protected]>

* Close canceled coroutine

Signed-off-by: Nadav Elkabets <[email protected]>

* Fixed behavior in test

Signed-off-by: Nadav Elkabets <[email protected]>

---------

Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: Tomoya Fujita <[email protected]>
fujitatomoya added a commit that referenced this pull request Jan 15, 2025
* Check if Task(Future) is canceled.

Signed-off-by: Tomoya Fujita <[email protected]>

* Close cancelled coroutine (#1394)

* Add FutureState

Signed-off-by: Nadav Elkabets <[email protected]>

* Close canceled coroutine

Signed-off-by: Nadav Elkabets <[email protected]>

* Fixed behavior in test

Signed-off-by: Nadav Elkabets <[email protected]>

---------

Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: Tomoya Fujita <[email protected]>

* address flake8 and pep257 failures.

Signed-off-by: Tomoya Fujita <[email protected]>

* Cancelled future is not done (#1397)

* Remove redundant coro.close

Signed-off-by: nadav <[email protected]>

* Only finished future is done

Signed-off-by: nadav <[email protected]>

* Add function _pending and fix checks

Signed-off-by: = <[email protected]>

* Replace check in done from pending to finished

Signed-off-by: = <[email protected]>

* Adapt test to new behavior

Signed-off-by: = <[email protected]>

* Add tests

Signed-off-by: = <[email protected]>

* Make changes within active task mutex

Signed-off-by: = <[email protected]>

---------

Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>

* keep the consistent behavior to avoid exception, and adjusted some tests accordingly.

Signed-off-by: Tomoya Fujita <[email protected]>

* revert doc section to raise the exception.

Signed-off-by: Tomoya Fujita <[email protected]>

* remove StrEnum and put logical operator in the beginning of line.

Signed-off-by: Tomoya Fujita <[email protected]>

* add more test to check Task state.

Signed-off-by: Tomoya Fujita <[email protected]>

---------

Signed-off-by: Tomoya Fujita <[email protected]>
Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
mergify bot pushed a commit that referenced this pull request Jan 17, 2025
* Check if Task(Future) is canceled.

Signed-off-by: Tomoya Fujita <[email protected]>

* Close cancelled coroutine (#1394)

* Add FutureState

Signed-off-by: Nadav Elkabets <[email protected]>

* Close canceled coroutine

Signed-off-by: Nadav Elkabets <[email protected]>

* Fixed behavior in test

Signed-off-by: Nadav Elkabets <[email protected]>

---------

Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: Tomoya Fujita <[email protected]>

* address flake8 and pep257 failures.

Signed-off-by: Tomoya Fujita <[email protected]>

* Cancelled future is not done (#1397)

* Remove redundant coro.close

Signed-off-by: nadav <[email protected]>

* Only finished future is done

Signed-off-by: nadav <[email protected]>

* Add function _pending and fix checks

Signed-off-by: = <[email protected]>

* Replace check in done from pending to finished

Signed-off-by: = <[email protected]>

* Adapt test to new behavior

Signed-off-by: = <[email protected]>

* Add tests

Signed-off-by: = <[email protected]>

* Make changes within active task mutex

Signed-off-by: = <[email protected]>

---------

Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>

* keep the consistent behavior to avoid exception, and adjusted some tests accordingly.

Signed-off-by: Tomoya Fujita <[email protected]>

* revert doc section to raise the exception.

Signed-off-by: Tomoya Fujita <[email protected]>

* remove StrEnum and put logical operator in the beginning of line.

Signed-off-by: Tomoya Fujita <[email protected]>

* add more test to check Task state.

Signed-off-by: Tomoya Fujita <[email protected]>

---------

Signed-off-by: Tomoya Fujita <[email protected]>
Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
(cherry picked from commit 9a144bf)

# Conflicts:
#	rclpy/rclpy/executors.py
#	rclpy/rclpy/task.py
#	rclpy/test/test_executor.py
mergify bot pushed a commit that referenced this pull request Jan 17, 2025
* Check if Task(Future) is canceled.

Signed-off-by: Tomoya Fujita <[email protected]>

* Close cancelled coroutine (#1394)

* Add FutureState

Signed-off-by: Nadav Elkabets <[email protected]>

* Close canceled coroutine

Signed-off-by: Nadav Elkabets <[email protected]>

* Fixed behavior in test

Signed-off-by: Nadav Elkabets <[email protected]>

---------

Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: Tomoya Fujita <[email protected]>

* address flake8 and pep257 failures.

Signed-off-by: Tomoya Fujita <[email protected]>

* Cancelled future is not done (#1397)

* Remove redundant coro.close

Signed-off-by: nadav <[email protected]>

* Only finished future is done

Signed-off-by: nadav <[email protected]>

* Add function _pending and fix checks

Signed-off-by: = <[email protected]>

* Replace check in done from pending to finished

Signed-off-by: = <[email protected]>

* Adapt test to new behavior

Signed-off-by: = <[email protected]>

* Add tests

Signed-off-by: = <[email protected]>

* Make changes within active task mutex

Signed-off-by: = <[email protected]>

---------

Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>

* keep the consistent behavior to avoid exception, and adjusted some tests accordingly.

Signed-off-by: Tomoya Fujita <[email protected]>

* revert doc section to raise the exception.

Signed-off-by: Tomoya Fujita <[email protected]>

* remove StrEnum and put logical operator in the beginning of line.

Signed-off-by: Tomoya Fujita <[email protected]>

* add more test to check Task state.

Signed-off-by: Tomoya Fujita <[email protected]>

---------

Signed-off-by: Tomoya Fujita <[email protected]>
Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
(cherry picked from commit 9a144bf)

# Conflicts:
#	rclpy/rclpy/executors.py
#	rclpy/rclpy/task.py
#	rclpy/test/test_executor.py
fujitatomoya added a commit that referenced this pull request Jan 22, 2025
* Check if Task(Future) is canceled. (#1377)

* Check if Task(Future) is canceled.

Signed-off-by: Tomoya Fujita <[email protected]>

* Close cancelled coroutine (#1394)

* Add FutureState

Signed-off-by: Nadav Elkabets <[email protected]>

* Close canceled coroutine

Signed-off-by: Nadav Elkabets <[email protected]>

* Fixed behavior in test

Signed-off-by: Nadav Elkabets <[email protected]>

---------

Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: Tomoya Fujita <[email protected]>

* address flake8 and pep257 failures.

Signed-off-by: Tomoya Fujita <[email protected]>

* Cancelled future is not done (#1397)

* Remove redundant coro.close

Signed-off-by: nadav <[email protected]>

* Only finished future is done

Signed-off-by: nadav <[email protected]>

* Add function _pending and fix checks

Signed-off-by: = <[email protected]>

* Replace check in done from pending to finished

Signed-off-by: = <[email protected]>

* Adapt test to new behavior

Signed-off-by: = <[email protected]>

* Add tests

Signed-off-by: = <[email protected]>

* Make changes within active task mutex

Signed-off-by: = <[email protected]>

---------

Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>

* keep the consistent behavior to avoid exception, and adjusted some tests accordingly.

Signed-off-by: Tomoya Fujita <[email protected]>

* revert doc section to raise the exception.

Signed-off-by: Tomoya Fujita <[email protected]>

* remove StrEnum and put logical operator in the beginning of line.

Signed-off-by: Tomoya Fujita <[email protected]>

* add more test to check Task state.

Signed-off-by: Tomoya Fujita <[email protected]>

---------

Signed-off-by: Tomoya Fujita <[email protected]>
Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
(cherry picked from commit 9a144bf)

# Conflicts:
#	rclpy/rclpy/executors.py
#	rclpy/rclpy/task.py
#	rclpy/test/test_executor.py

* resolve conflicts.

Signed-off-by: Tomoya Fujita <[email protected]>

* _spin_once_until_future_complete does not exist.

Signed-off-by: Tomoya Fujita <[email protected]>

---------

Signed-off-by: Tomoya Fujita <[email protected]>
Co-authored-by: Tomoya Fujita <[email protected]>
fujitatomoya added a commit that referenced this pull request Jan 22, 2025
* Check if Task(Future) is canceled. (#1377)

* Check if Task(Future) is canceled.

Signed-off-by: Tomoya Fujita <[email protected]>

* Close cancelled coroutine (#1394)

* Add FutureState

Signed-off-by: Nadav Elkabets <[email protected]>

* Close canceled coroutine

Signed-off-by: Nadav Elkabets <[email protected]>

* Fixed behavior in test

Signed-off-by: Nadav Elkabets <[email protected]>

---------

Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: Tomoya Fujita <[email protected]>

* address flake8 and pep257 failures.

Signed-off-by: Tomoya Fujita <[email protected]>

* Cancelled future is not done (#1397)

* Remove redundant coro.close

Signed-off-by: nadav <[email protected]>

* Only finished future is done

Signed-off-by: nadav <[email protected]>

* Add function _pending and fix checks

Signed-off-by: = <[email protected]>

* Replace check in done from pending to finished

Signed-off-by: = <[email protected]>

* Adapt test to new behavior

Signed-off-by: = <[email protected]>

* Add tests

Signed-off-by: = <[email protected]>

* Make changes within active task mutex

Signed-off-by: = <[email protected]>

---------

Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>

* keep the consistent behavior to avoid exception, and adjusted some tests accordingly.

Signed-off-by: Tomoya Fujita <[email protected]>

* revert doc section to raise the exception.

Signed-off-by: Tomoya Fujita <[email protected]>

* remove StrEnum and put logical operator in the beginning of line.

Signed-off-by: Tomoya Fujita <[email protected]>

* add more test to check Task state.

Signed-off-by: Tomoya Fujita <[email protected]>

---------

Signed-off-by: Tomoya Fujita <[email protected]>
Signed-off-by: Nadav Elkabets <[email protected]>
Signed-off-by: nadav <[email protected]>
Signed-off-by: = <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
Co-authored-by: Nadav Elkabets <[email protected]>
(cherry picked from commit 9a144bf)

# Conflicts:
#	rclpy/rclpy/executors.py
#	rclpy/rclpy/task.py
#	rclpy/test/test_executor.py

* resolve conflicts.

Signed-off-by: Tomoya Fujita <[email protected]>

* _spin_once_until_future_complete does not exist.

Signed-off-by: Tomoya Fujita <[email protected]>

---------

Signed-off-by: Tomoya Fujita <[email protected]>
Co-authored-by: Tomoya Fujita <[email protected]>
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.

2 participants