Skip to main content

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: manual ReceiveNextEvent dispatch, the part macOS won't do for you (DEV.md has the probe history)
  • FdWatch: a CFSocket source that wakes the pump when a registered file descriptor becomes ready
  • post_wake: post a no-op Carbon event from any thread, to break the pump out of its wait
  • call_later: a CFRunLoopTimer that calls back into Python
  • run_app/quit_app: for callers who want Carbon's own RunApplicationEventLoop to 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)

Source distribution for cfloop 0.1.0
File Size Uploaded
cfloop-0.1.0.tar.gz 15.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for cfloop 0.1.0
File Interpreter ABI Platform
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 log

Release 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 log

Release 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

Release history Release notifications | RSS feed

This release

0.1.0 This release

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page