Skip to content

Exception when awaiting call_async() #1588

@bananajr

Description

@bananajr

Generated by Generative AI

No response

Operating System:

ros:jazzy-ros-core (ubuntu:noble)

ROS version or commit hash:

Jazzy 7.1.9, Rolling 10.0.3

RMW implementation (if applicable):

rmw_cyclonedds_cpp

RMW Configuration (if applicable):

No response

Client library (if applicable):

rclpy

'ros2 doctor --report' output

No response

Steps to reproduce issue

  1. Create a service that does not return immediately
  2. Create a client of the service
  3. Call the service via asyncio w/ await service.call_async(request)

Expected behavior

Service call is awaited in the client and returns successfully.

Actual behavior

All code that assumes call_async() is awaitable will, as of 7.1.9, exit on exception RuntimeError: Task got bad yield: <rclpy.task.Future object at 0x74d4e2623ef0> if the Future pends.

Additional information

This is a regression in Jazzy 7.1.9 due to the change to Future.__await__ in #1560, backported from #1469, Rolling 10.0.3 @bjsowa.

rclpy.Future implements __await__ indicating it is intended for use with asyncio. Previously, rclpy.Future.__await__ yielded None, which asyncio responds to by checking the future again at the next iteration of the event loop. As of #1560, it yields itself. Because rclpy.Future is not a "Future-like object" due to missing get_loop() and _asyncio_future_blocking apis (as discussed in #1399) asyncio throws the exception.

Noting that #1560 is a backport of #1469 into Rolling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions