Skip to content

Foreign async RPC handler registration after connect panics (no reactor running) #59

Description

@pham-tuan-binh

Summary

Registering a foreign (Python) async RPC handler after connect() raises:

InternalError: there is no reactor running, must be called from the context of a Tokio 1.x runtime

The failure is at register_rpc_method itself, before any perform_rpc. The SDK's register_rpc_method runs on the asyncio thread, which has no tokio reactor.

Pre-existing

Found while building PR #58. Reproduces identically through the Python facade on unmodified main, so it is not related to the role-split bindings.

Reproduce

async def handler(data): return f"pong:{data.payload}"
await robot.connect(url, token)
robot.register_rpc_method("ping", handler)  # raises here

Workaround (supported path)

Register handlers before connect(). The core stores pre-connect handlers and applies them inside connect(), which runs on the tokio runtime. PR #58's test_rpc_roundtrip uses this path and passes.

Possible fix directions

  • Marshal the SDK register_rpc_method call onto the tokio runtime instead of invoking it on the caller's asyncio thread.
  • Or document pre-connect registration as the only supported path and reject post-connect registration with a clear error rather than a panic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions