cfloop
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
Development
pip install -e .[dev]
maturin develop && pytest -q
Build
ship-rs-build
Release
maturin develop && pytest -q
ship-release
ship-release tags the Cargo version, leaves wheel publication to GitHub Actions, then bumps the project.
Metadata
Release files for cfloop 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cfloop-0.1.0.tar.gz | 15.7 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cfloop-0.1.0-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
| cfloop-0.1.0-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
Total release size: 444.1 kB
Release files / cfloop-0.1.0.tar.gz
| Download URL | cfloop-0.1.0.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0beb4661f3b00426f709b40b0419a20da814e244c8d386616e4b5df56129dd6
|
|
BLAKE2b-256 checksum How to use checksums |
942e0bc4ce08f8822a55ec45a09d8b078593e4f74df392ca9f80fc989f92d9ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.
Transparency logRelease files / cfloop-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | cfloop-0.1.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 214.5 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6d47cfe864b8150b774722d4b40c3289b1ec22def02a20a91992db69b030a160
|
|
BLAKE2b-256 checksum How to use checksums |
0ddae328e9cab24357011a89826f17d060bba72183ccfcc2e2307229a4865d55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.
Transparency logRelease files / cfloop-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | cfloop-0.1.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 214.0 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
38256aeb7b5caa91a654a3b1a53bce11822bf773d14e78de2a1d2fde1c560860
|
|
BLAKE2b-256 checksum How to use checksums |
15657fa170288f4231bf8090ff30e4bbeb753f7c001dda021bba7a7f5509a845
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.
Transparency log