Skip to main content

Lightweight asyncio-like library for MicroPython, built around native Python coroutines.

Project description

uasyncio is MicroPython’s asynchronous sheduling library, roughly modeled after CPython’s asyncio.

uasyncio doesn’t use naive always-iterating scheduling algorithm, but performs a real time-based scheduling, which allows it (and thus the whole system) to sleep when there is nothing to do (actual implementation of that depends on I/O scheduling algorithm which actually performs the wait operation).

Major conceptual differences to asyncio:

  • Avoids defining a notion of Future, and especially wrapping coroutines in Futures, like CPython asyncio does. uasyncio works directly with coroutines (and callbacks).

  • uasyncio uses wrap-around millisecond timebase (as native to all MicroPython ports.)

  • Instead of single large package, number of subpackages are provided (each installable separately).

Specific differences:

  • For millisecond scheduling, loop.call_later_ms() and uasyncio.sleep_ms() are provided.

  • As there’s no monotonic time, loop.call_at() is not provided. Instead, there’s loop.call_at_() which is considered an internal function and has slightly different signature.

  • call_* funcions don’t return Handle and callbacks scheduled by them aren’t cancellable. If they need to be cancellable, they should accept an object as an argument, and a “cancel” flag should be set in the object, for a callback to test.

  • Future object is not available.

  • ensure_future() and Task() perform just scheduling operations and return a native coroutine, not Future/Task objects.

  • Some other functions are not (yet) implemented.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

micropython-uasyncio-1.2.4.tar.gz (3.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page