1
- # Use of MicroPython uasyncio library
1
+ # 1. The MicroPython uasyncio library
2
2
3
3
This GitHub repository consists of the following parts:
4
4
* [ A tutorial] ( ./TUTORIAL.md ) An introductory tutorial on asynchronous
@@ -19,19 +19,22 @@ This GitHub repository consists of the following parts:
19
19
boards to communicate without using a UART. Primarily intended to enable a
20
20
a Pyboard-like device to achieve bidirectional communication with an ESP8266.
21
21
22
- # Installation of uasyncio
22
+ # 2. Installation of uasyncio
23
23
24
24
Firstly install the latest version of ` micropython-uasyncio ` . To use queues,
25
25
also install the ` micropython-uasyncio.queues ` module. A ` Lock ` synchronisation
26
26
primitive is provided by ` micropython-uasyncio.synchro ` .
27
27
28
- Instructions on installing library modules may be found [ here] ( https://github.com/micropython/micropython-lib ) .
28
+ Instructions on installing library modules may be found
29
+ [ here] ( https://github.com/micropython/micropython-lib ) .
29
30
30
- On networked hardware, upip may be run locally. The [ tutorial ] ( ./TUTORIAL.md#installing-uasyncio-on-bare-metal )
31
- has instructions for a method of installation on non-networked baremetal
32
- targets.
31
+ On networked hardware, upip may be run locally. The
32
+ [ tutorial ] ( ./TUTORIAL.md#installing-uasyncio-on-bare-metal ) has instructions
33
+ for methods of installation on non-networked baremetal targets.
33
34
34
- # Current development state
35
+ # 3. uasyncio development state
36
+
37
+ These notes are intended for users familiar with ` asyncio ` under CPython.
35
38
36
39
The MicroPython language is based on CPython 3.4. The ` uasyncio ` library
37
40
supports a subset of the CPython 3.4 ` asyncio ` library with some V3.5
@@ -61,23 +64,12 @@ cancellation.
61
64
62
65
Classes ` Task ` and ` Future ` are not supported.
63
66
64
- ## Synchronisation Primitives and Task Cancellation
65
-
66
- The library ` asyn.py ` provides 'micro' implementations of the ` asyncio `
67
- [ synchronisation primitives] ( https://docs.python.org/3/library/asyncio-sync.html ) .
68
- Because ` uasyncio ` does not support ` Task ` and ` Future ` classes ` asyncio `
69
- features such as ` wait ` and ` gather ` are unavailable. A ` Barrier ` class enables
70
- coroutines to be similarly synchronised. Coroutine cancellation is performed in
71
- a special efficient manner in ` uasyncio ` . The ` asyn ` library enhances this by
72
- facilitating options to pause until cancellation is complete and to check the
73
- status of individual coroutines.
67
+ ## 3.1 Asynchronous I/O
74
68
75
- ## Asynchronous I/O
69
+ Asynchronous I/O works with devices whose drivers support streaming, such as
70
+ UARTs.
76
71
77
- At the time of writing this was under development. Asynchronous I/O works with
78
- devices whose drivers support streaming, such as the UART.
79
-
80
- ## Time values
72
+ ## 3.2 Time values
81
73
82
74
For timing asyncio uses floating point values of seconds. The ` uasyncio.sleep `
83
75
method accepts floats (including sub-second values) or integers. Note that in
@@ -89,3 +81,17 @@ millisecond level functions (with integer arguments) employed where necessary.
89
81
The ` loop.time ` method returns an integer number of milliseconds whereas
90
82
CPython returns a floating point number of seconds. ` call_at ` follows the
91
83
same convention.
84
+
85
+ # 4. The asyn.py library
86
+
87
+ This library provides 'micro' implementations of the ` asyncio ` synchronisation
88
+ primitives [ CPython docs] ( https://docs.python.org/3/library/asyncio-sync.html ) .
89
+
90
+ It also supports a ` Barrier ` class to facilitate coroutine synchronisation.
91
+
92
+ Coroutine cancellation is performed in an efficient manner in ` uasyncio ` . The
93
+ ` asyn ` library enhances this by enabling the cancelling coro to pause until
94
+ cancellation is complete and to check the 'running' status of individual
95
+ coroutines.
96
+
97
+ A lightweight implementation of ` asyncio.gather ` is provided.
0 commit comments