-
Notifications
You must be signed in to change notification settings - Fork 257
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
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 –
asynciois 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 withloop.call_at(). -
AbstractExecutor base class
Define anAbstractExecutor(similar toasyncio.AbstractEventLoop) to unify typing acrossExecutor,EventsExecutor, andAsyncioExecutor.
Related Issues & PRs
- async wait/sleep implementation #1234 – async wait/sleep implementation
- Tasks that raise an exception crash the entire executor, even when the exception is caught #1098 – Tasks that raise an exception crash the entire executor
- Runtime error when a long async callback is triggered #962 – Runtime error when a long async callback is triggered
- Ignore exceptions raised in user created tasks #1395 – Ignore exceptions raised in user-created tasks
- Enable limited use of asyncio with executors #971 – Enable limited use of asyncio with executors
bjsowa, ryleu, iliazeus, lixian-acemate, 2lian and 1 moreSpeedySpeedBoii, Nico0302, lixian-acemate, 2lian and LoyVanBeekryleu
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed