Skip to content

feat(python): native async API via pyo3-async-runtimes (AsyncSerialMonitor, AsyncDaemon) #65

Closed

Description

@zackees

Split out from #18 item 3.

Problem

The Python bindings in fbuild-python expose only synchronous methods. FastLED's FbuildSerialAdapter._run_in_thread wraps every call in a thread executor so async callers don't block their event loop, but this generates an asyncio warning under some configurations and adds latency.

Proposed fix

Add AsyncSerialMonitor, AsyncDaemon, etc. that use pyo3-async-runtimes to expose async def-callable methods directly under asyncio.run(...).

  • Existing sync SerialMonitor / Daemon / DaemonConnection stay for backward compatibility.
  • New async classes are purely additive.

Scope

  • Add pyo3-async-runtimes (or successor) to crates/fbuild-python/Cargo.toml.
  • Wrap each long-running operation (serial read/write, send_op) as an async method on a new class.
  • Tests verify asyncio.run(...) works and does not spin up an extra thread pool.

Non-goals

  • Migrating or deprecating the sync API. Sync stays.

Context

Filed during the issue consolidation that closed tracker #18. See #18 for the original framing.

Activity

  1. zackees commented on Apr 18, 2026

    @zackees
    MemberAuthor

    Progress update — substantial async surface merged:

    Sync API stayed untouched throughout (additive only, per the issue's Non-goals).

    Remaining: WebSocket-backed AsyncSerialMonitor methods — read_lines, write, write_json_rpc, __aenter__/__aexit__. Blocked on refactoring the shared WebSocket session state to be Send + Sync across .await points (flagged in PR #73's scaffold doc-comment). Picking that up next.

  2. added a commit that references this issue on Apr 18, 2026
    e905230
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions