|
| 1 | +uasyncio |
| 2 | +======== |
| 3 | + |
| 4 | +uasyncio is MicroPython's asynchronous sheduling library, roughly |
| 5 | +modeled after CPython's asyncio. |
| 6 | + |
| 7 | +uasyncio doesn't use naive always-iterating scheduling algorithm, |
| 8 | +but performs a real time-based scheduling, which allows it (and |
| 9 | +thus the whole system) to sleep when there is nothing to do (actual |
| 10 | +implementation of that depends on I/O scheduling algorithm which |
| 11 | +actually performs the wait operation). |
| 12 | + |
| 13 | +Major conceptual differences to asyncio: |
| 14 | + |
| 15 | +* Avoids defining a notion of Future, and especially wrapping coroutines |
| 16 | + in Futures, like CPython asyncio does. uasyncio works directly with |
| 17 | + coroutines (and callbacks). |
| 18 | +* uasyncio uses wrap-around millisecond timebase (as native to all |
| 19 | + MicroPython ports.) |
| 20 | +* Instead of single large package, number of subpackages are provided |
| 21 | + (each installable separately). |
| 22 | + |
| 23 | +Specific differences: |
| 24 | + |
| 25 | +* For millisecond scheduling, ``loop.call_later_ms()`` and |
| 26 | + ``uasyncio.sleep_ms()`` are provided. |
| 27 | +* As there's no monotonic time, ``loop.call_at()`` is not provided. |
| 28 | + Instead, there's ``loop.call_at_()`` which is considered an internal |
| 29 | + function and has slightly different signature. |
| 30 | +* ``call_*`` funcions don't return Handle and callbacks scheduled by |
| 31 | + them aren't cancellable. If they need to be cancellable, they should |
| 32 | + accept an object as an argument, and a "cancel" flag should be set |
| 33 | + in the object, for a callback to test. |
| 34 | +* ``Future`` object is not available. |
| 35 | +* ``ensure_future()`` and ``Task()`` perform just scheduling operations |
| 36 | + and return a native coroutine, not Future/Task objects. |
| 37 | +* Some other functions are not (yet) implemented. |
0 commit comments