Skip to content

Commit 9092909

Browse files
jimmodpgeorge
authored andcommitted
docs: Rename uasyncio to asyncio.
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <[email protected]>
1 parent 6027c41 commit 9092909

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

docs/library/uasyncio.rst renamed to docs/library/asyncio.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
:mod:`uasyncio` --- asynchronous I/O scheduler
2-
==============================================
1+
:mod:`asyncio` --- asynchronous I/O scheduler
2+
=============================================
33

4-
.. module:: uasyncio
4+
.. module:: asyncio
55
:synopsis: asynchronous I/O scheduler for writing concurrent code
66

77
|see_cpython_module|
88
`asyncio <https://docs.python.org/3.8/library/asyncio.html>`_
99

1010
Example::
1111

12-
import uasyncio
12+
import asyncio
1313

1414
async def blink(led, period_ms):
1515
while True:
1616
led.on()
17-
await uasyncio.sleep_ms(5)
17+
await asyncio.sleep_ms(5)
1818
led.off()
19-
await uasyncio.sleep_ms(period_ms)
19+
await asyncio.sleep_ms(period_ms)
2020

2121
async def main(led1, led2):
22-
uasyncio.create_task(blink(led1, 700))
23-
uasyncio.create_task(blink(led2, 400))
24-
await uasyncio.sleep_ms(10_000)
22+
asyncio.create_task(blink(led1, 700))
23+
asyncio.create_task(blink(led2, 400))
24+
await asyncio.sleep_ms(10_000)
2525

2626
# Running on a pyboard
2727
from pyb import LED
28-
uasyncio.run(main(LED(1), LED(2)))
28+
asyncio.run(main(LED(1), LED(2)))
2929

3030
# Running on a generic board
3131
from machine import Pin
32-
uasyncio.run(main(Pin(1), Pin(2)))
32+
asyncio.run(main(Pin(1), Pin(2)))
3333

3434
Core functions
3535
--------------
@@ -71,9 +71,9 @@ Additional functions
7171
than *timeout* seconds. If *awaitable* is not a task then a task will be
7272
created from it.
7373

74-
If a timeout occurs, it cancels the task and raises ``uasyncio.TimeoutError``:
74+
If a timeout occurs, it cancels the task and raises ``asyncio.TimeoutError``:
7575
this should be trapped by the caller. The task receives
76-
``uasyncio.CancelledError`` which may be ignored or trapped using ``try...except``
76+
``asyncio.CancelledError`` which may be ignored or trapped using ``try...except``
7777
or ``try...finally`` to run cleanup code.
7878

7979
Returns the return value of *awaitable*.
@@ -108,7 +108,7 @@ class Task
108108

109109
.. method:: Task.cancel()
110110

111-
Cancel the task by injecting ``uasyncio.CancelledError`` into it. The task may
111+
Cancel the task by injecting ``asyncio.CancelledError`` into it. The task may
112112
ignore this exception. Cleanup code may be run by trapping it, or via
113113
``try ... finally``.
114114

@@ -148,7 +148,7 @@ class ThreadSafeFlag
148148
.. class:: ThreadSafeFlag()
149149

150150
Create a new flag which can be used to synchronise a task with code running
151-
outside the uasyncio loop, such as other threads, IRQs, or scheduler
151+
outside the asyncio loop, such as other threads, IRQs, or scheduler
152152
callbacks. Flags start in the cleared state. The class does not currently
153153
work under the Unix build of MicroPython.
154154

docs/library/espnow.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ Supporting asyncio
632632
------------------
633633

634634
A supplementary module (`aioespnow`) is available to provide
635-
:doc:`asyncio<uasyncio>` support.
635+
:doc:`asyncio<asyncio>` support.
636636

637637
**Note:** Asyncio support is available on all ESP32 targets as well as those
638638
ESP8266 boards which include the asyncio module (ie. ESP8266 devices with at
@@ -642,7 +642,7 @@ A small async server example::
642642

643643
import network
644644
import aioespnow
645-
import uasyncio as asyncio
645+
import asyncio
646646

647647
# A WLAN interface must be active to send()/recv()
648648
network.WLAN(network.STA_IF).active(True)
@@ -680,7 +680,7 @@ A small async server example::
680680
asyncio.run(main(e, peer, 120, 10))
681681

682682
.. module:: aioespnow
683-
:synopsis: ESP-NOW :doc:`uasyncio` support
683+
:synopsis: ESP-NOW :doc:`asyncio` support
684684

685685
.. class:: AIOESPNow()
686686

docs/library/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ library.
5757
:maxdepth: 1
5858

5959
array.rst
60+
asyncio.rst
6061
binascii.rst
6162
builtins.rst
6263
cmath.rst
@@ -77,7 +78,6 @@ library.
7778
struct.rst
7879
sys.rst
7980
time.rst
80-
uasyncio.rst
8181
zlib.rst
8282
_thread.rst
8383

docs/library/machine.I2S.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ I2S objects can be created and initialized using::
4747
3 modes of operation are supported:
4848
- blocking
4949
- non-blocking
50-
- uasyncio
50+
- asyncio
5151

5252
blocking::
5353

@@ -63,13 +63,13 @@ non-blocking::
6363
audio_in.irq(i2s_callback) # i2s_callback is called when buf is filled
6464
num_read = audio_in.readinto(buf) # returns immediately
6565

66-
uasyncio::
66+
asyncio::
6767

68-
swriter = uasyncio.StreamWriter(audio_out)
68+
swriter = asyncio.StreamWriter(audio_out)
6969
swriter.write(buf)
7070
await swriter.drain()
7171

72-
sreader = uasyncio.StreamReader(audio_in)
72+
sreader = asyncio.StreamReader(audio_in)
7373
num_read = await sreader.readinto(buf)
7474

7575
Some codec devices like the WM8960 or SGTL5000 require separate initialization

docs/reference/isr_rules.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,28 +219,28 @@ Exceptions
219219
If an ISR raises an exception it will not propagate to the main loop. The interrupt will be disabled unless the
220220
exception is handled by the ISR code.
221221

222-
Interfacing to uasyncio
223-
-----------------------
222+
Interfacing to asyncio
223+
----------------------
224224

225-
When an ISR runs it can preempt the `uasyncio` scheduler. If the ISR performs a `uasyncio`
225+
When an ISR runs it can preempt the `asyncio` scheduler. If the ISR performs a `asyncio`
226226
operation the scheduler's operation can be disrupted. This applies whether the interrupt is hard
227227
or soft and also applies if the ISR has passed execution to another function via
228228
`micropython.schedule`. In particular creating or cancelling tasks is invalid in an ISR context.
229-
The safe way to interact with `uasyncio` is to implement a coroutine with synchronisation performed by
230-
`uasyncio.ThreadSafeFlag`. The following fragment illustrates the creation of a task in response
229+
The safe way to interact with `asyncio` is to implement a coroutine with synchronisation performed by
230+
`asyncio.ThreadSafeFlag`. The following fragment illustrates the creation of a task in response
231231
to an interrupt:
232232

233233
.. code:: python
234234
235-
tsf = uasyncio.ThreadSafeFlag()
235+
tsf = asyncio.ThreadSafeFlag()
236236
237237
def isr(_): # Interrupt handler
238238
tsf.set()
239239
240240
async def foo():
241241
while True:
242242
await tsf.wait()
243-
uasyncio.create_task(bar())
243+
asyncio.create_task(bar())
244244
245245
In this example there will be a variable amount of latency between the execution of the ISR and the execution
246246
of ``foo()``. This is inherent to cooperative scheduling. The maximum latency is application

0 commit comments

Comments
 (0)