Skip to content

Feature: asyncio executor #1461

@nadavelkabets

Description

@nadavelkabets

Motivation

Current wait_set based executors are highly inefficient and don’t integrate cleanly with Python’s asyncio ecosystem.
Examples of inefficiencies in the wait_set executor:

  • Reoccurring construction of the wait set
  • Revisiting blocked tasks every iteration
  • Busy looping while a callback group is blocking

Advantages of integrating with asyncio:

  • Better support for asynchronous code – take advantage of many existing features like call_later(), sleep(), and task exception handling
  • Easy integration with large Python libraries – FastAPI, pyserial-asyncio, pytransitions, aiohttp, python-can, etc.
  • High performance – asyncio is already far more optimized than the existing wait_set executor, and libraries like uvloop are available for even higher performance, matching the current cpp implementation of the EventsExecutor
  • Reduction in code duplication - lower maintenance costs and library complexity by transitioning to a built in event loop implementation

Proposed Implementation

  • Shared dispatch logic
    Re-use the existing Python executor’s “take_entity” functions to pull items from the queue.

  • Timers via asyncio
    Replace the DelayedEventsThread with loop.call_at().

  • AbstractExecutor base class
    Define an AbstractExecutor (similar to asyncio.AbstractEventLoop) to unify typing across Executor, EventsExecutor, and AsyncioExecutor.

Related Issues & PRs

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions