Feature: add executor.create_future()#1495
Conversation
|
@sloretz @fujitatomoya @mjcarroll @wjwwood @ahcorde |
fujitatomoya
left a comment
There was a problem hiding this comment.
i think this makes sense, that makes the explicit association to the executor, the future is tied to the executor that created it. and it also aligns with create_task method in API consistency.
i would like to have another approval before merge.
bjsowa
left a comment
There was a problem hiding this comment.
LGTM. I would also change the other tests in test_executor to use the new method for creating futures.
|
Also, shouldn't the |
@bjsowa @fujitatomoya rclpy/rclpy/rclpy/executors.py Line 516 in 0fbd01a The same case applies to ActionClient (or any other Waitable) rclpy/rclpy/rclpy/executors.py Line 566 in 0fbd01a
Done |
bjsowa
left a comment
There was a problem hiding this comment.
Client and ActionClient initialize the Future object without an executor by design.
Currently, users are able to execute client.call_async() before initializing an executor.
To allow this behavior, Future is initialized without an executor, and the executor is set when processing the service response.
Oh, I haven't realized that. That makes sense.
|
@Mergifyio rebase |
Signed-off-by: Nadav Elkabets <elnadav12@gmail.com>
Signed-off-by: Nadav Elkabets <elnadav12@gmail.com>
✅ Branch has been successfully rebased |
9208dbf to
fb025e0
Compare
|
Pulls: #1495 |
|
@fujitatomoya could you run CI again? I believe Linux failed for unrelated reasons. |
|
@fujitatomoya can we proceed to merge this PR? |
|
https://ci.ros2.org/job/ci_linux-rhel/4284/ are known issues and unrelated. |
|
@fujitatomoya thank you for helping to merge this PR. I really appreciate your support🙏 |
|
i think that it is straight-forward for kilted, but maybe there can be conflict for jazzy. but i think that it is backportable. |
|
@Mergifyio backport kilted jazzy |
✅ Backports have been createdDetails
|
* feature: add create_future and test Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> * Use create_future in all executor tests Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> --------- Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> (cherry picked from commit bcdd663)
* feature: add create_future and test Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> * Use create_future in all executor tests Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> --------- Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> (cherry picked from commit bcdd663) # Conflicts: # rclpy/src/rclpy/events_executor/events_executor.cpp # rclpy/src/rclpy/events_executor/events_executor.hpp # rclpy/test/test_executor.py
* feature: add create_future and test * Use create_future in all executor tests --------- (cherry picked from commit bcdd663) Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> Co-authored-by: Nadav Elkabets <32939935+nadavelkabets@users.noreply.github.com>
* Feature: add executor.create_future() (#1495) * feature: add create_future and test Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> * Use create_future in all executor tests Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> --------- Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> (cherry picked from commit bcdd663) # Conflicts: # rclpy/src/rclpy/events_executor/events_executor.cpp # rclpy/src/rclpy/events_executor/events_executor.hpp # rclpy/test/test_executor.py * resolve conflicts. Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com> --------- Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Co-authored-by: Nadav Elkabets <32939935+nadavelkabets@users.noreply.github.com> Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
* Feature: add executor.create_future() (ros2#1495) * feature: add create_future and test Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> * Use create_future in all executor tests Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> --------- Signed-off-by: Nadav Elkabets <elnadav12@gmail.com> (cherry picked from commit bcdd663) # Conflicts: # rclpy/src/rclpy/events_executor/events_executor.cpp # rclpy/src/rclpy/events_executor/events_executor.hpp # rclpy/test/test_executor.py * resolve conflicts. Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com> --------- Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Co-authored-by: Nadav Elkabets <32939935+nadavelkabets@users.noreply.github.com> Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Part of #1399 and #1469.
To allow an executor to reschedule a task when a future stops blocking, it is crucial that the future is attached to the same executor.
Currently, users are able to initialize a Future instance without supplying the executor parameter.
This behavior is necessary to allow calling client.call_async() before attaching the node to an executor (the future is attached to the running executor when processing the service response).
In asyncio, loop.create_future() was added to discourage users from initializing the Future class directly.
I suggest we follow the same path.