An asyncio event loop on macOS's CFRunLoop, so coroutines, Carbon events, and main-queue delegates share the main thread.
import asyncio, cfloop
async def main():
await asyncio.sleep(1) # Carbon events and main-queue callbacks keep dispatching meanwhile
# the asyncio.run twin, which must own the main thread
cfloop.run(main())
# or compose it yourself (also asyncio.Runner)
asyncio.run(main(), loop_factory=cfloop.new_event_loop)That is the whole API. The loop is a stock asyncio.SelectorEventLoop whose selector waits inside a Carbon event pump instead of a bare kqueue. So whenever asyncio is idle, Carbon events dispatch (hotkeys included), CFRunLoop timers and sources fire, and the main dispatch queue drains. Everything asyncio provides is inherited, not reimplemented: tasks, subprocesses, signal handling, debug mode's slow-callback warnings. macOS only, Python 3.12+.
The substrate is a small pyo3 module:
pump: manualReceiveNextEventdispatch, the part macOS won't do for you (DEV.mdhas the probe history)FdWatch: aCFSocketsource that wakes the pump when a registered file descriptor becomes readypost_wake: post a no-op Carbon event from any thread, to break the pump out of its waitcall_later: aCFRunLoopTimerthat calls back into Pythonrun_app/quit_app: for callers who want Carbon's ownRunApplicationEventLoopto own the thread instead
pip install -e .[dev]
maturin develop && pytest -qship-rs-buildmaturin develop && pytest -q
ship-releaseship-release tags the Cargo version, leaves wheel publication to GitHub Actions, then bumps the project.