Skip to content

Commit 2fbc08c

Browse files
jimmodpgeorge
authored andcommitted
extmod/asyncio: Rename uasyncio to asyncio.
The asyncio module now has much better CPython compatibility and deserves to be just called "asyncio". This will avoid people having to write `from uasyncio import asyncio`. Renames all files, and updates port manifests to use the new path. Also renames the built-in _uasyncio to _asyncio. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <[email protected]>
1 parent ed962f1 commit 2fbc08c

File tree

28 files changed

+47
-47
lines changed

28 files changed

+47
-47
lines changed

extmod/uasyncio/__init__.py extmod/asyncio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MicroPython uasyncio module
1+
# MicroPython asyncio module
22
# MIT license; Copyright (c) 2019 Damien P. George
33

44
from .core import *

extmod/uasyncio/core.py extmod/asyncio/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# MicroPython uasyncio module
1+
# MicroPython asyncio module
22
# MIT license; Copyright (c) 2019 Damien P. George
33

44
from time import ticks_ms as ticks, ticks_diff, ticks_add
55
import sys, select
66

77
# Import TaskQueue and Task, preferring built-in C code over Python code
88
try:
9-
from _uasyncio import TaskQueue, Task
9+
from _asyncio import TaskQueue, Task
1010
except:
1111
from .task import TaskQueue, Task
1212

extmod/uasyncio/event.py extmod/asyncio/event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MicroPython uasyncio module
1+
# MicroPython asyncio module
22
# MIT license; Copyright (c) 2019-2020 Damien P. George
33

44
from . import core

extmod/uasyncio/funcs.py extmod/asyncio/funcs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MicroPython uasyncio module
1+
# MicroPython asyncio module
22
# MIT license; Copyright (c) 2019-2022 Damien P. George
33

44
from . import core

extmod/uasyncio/lock.py extmod/asyncio/lock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MicroPython uasyncio module
1+
# MicroPython asyncio module
22
# MIT license; Copyright (c) 2019-2020 Damien P. George
33

44
from . import core

extmod/uasyncio/manifest.py extmod/asyncio/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This list of package files doesn't include task.py because that's provided
22
# by the C module.
33
package(
4-
"uasyncio",
4+
"asyncio",
55
(
66
"__init__.py",
77
"core.py",

extmod/uasyncio/stream.py extmod/asyncio/stream.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MicroPython uasyncio module
1+
# MicroPython asyncio module
22
# MIT license; Copyright (c) 2019-2020 Damien P. George
33

44
from . import core

extmod/uasyncio/task.py extmod/asyncio/task.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MicroPython uasyncio module
1+
# MicroPython asyncio module
22
# MIT license; Copyright (c) 2019-2020 Damien P. George
33

44
# This file contains the core TaskQueue based on a pairing heap, and the core Task class.

extmod/extmod.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set(MICROPY_SOURCE_EXTMOD
1919
${MICROPY_EXTMOD_DIR}/modlwip.c
2020
${MICROPY_EXTMOD_DIR}/modnetwork.c
2121
${MICROPY_EXTMOD_DIR}/modonewire.c
22-
${MICROPY_EXTMOD_DIR}/moduasyncio.c
22+
${MICROPY_EXTMOD_DIR}/modasyncio.c
2323
${MICROPY_EXTMOD_DIR}/modbinascii.c
2424
${MICROPY_EXTMOD_DIR}/modcryptolib.c
2525
${MICROPY_EXTMOD_DIR}/moductypes.c

extmod/extmod.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SRC_EXTMOD_C += \
1111
extmod/machine_signal.c \
1212
extmod/machine_spi.c \
1313
extmod/machine_timer.c \
14+
extmod/modasyncio.c \
1415
extmod/modbinascii.c \
1516
extmod/modbluetooth.c \
1617
extmod/modbtree.c \
@@ -31,7 +32,6 @@ SRC_EXTMOD_C += \
3132
extmod/modssl_axtls.c \
3233
extmod/modssl_mbedtls.c \
3334
extmod/modtime.c \
34-
extmod/moduasyncio.c \
3535
extmod/moductypes.c \
3636
extmod/modwebrepl.c \
3737
extmod/modwebsocket.c \

extmod/moduasyncio.c extmod/modasyncio.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "py/pairheap.h"
3030
#include "py/mphal.h"
3131

32-
#if MICROPY_PY_UASYNCIO
32+
#if MICROPY_PY_ASYNCIO
3333

3434
// Used when task cannot be guaranteed to be non-NULL.
3535
#define TASK_PAIRHEAP(task) ((task) ? &(task)->pairheap : NULL)
@@ -155,8 +155,8 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
155155
/******************************************************************************/
156156
// Task class
157157

158-
// This is the core uasyncio context with cur_task, _task_queue and CancelledError.
159-
STATIC mp_obj_t uasyncio_context = MP_OBJ_NULL;
158+
// This is the core asyncio context with cur_task, _task_queue and CancelledError.
159+
STATIC mp_obj_t asyncio_context = MP_OBJ_NULL;
160160

161161
STATIC mp_obj_t task_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
162162
mp_arg_check_num(n_args, n_kw, 1, 2, false);
@@ -168,7 +168,7 @@ STATIC mp_obj_t task_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
168168
self->state = TASK_STATE_RUNNING_NOT_WAITED_ON;
169169
self->ph_key = MP_OBJ_NEW_SMALL_INT(0);
170170
if (n_args == 2) {
171-
uasyncio_context = args[1];
171+
asyncio_context = args[1];
172172
}
173173
return MP_OBJ_FROM_PTR(self);
174174
}
@@ -186,7 +186,7 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) {
186186
return mp_const_false;
187187
}
188188
// Can't cancel self (not supported yet).
189-
mp_obj_t cur_task = mp_obj_dict_get(uasyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_cur_task));
189+
mp_obj_t cur_task = mp_obj_dict_get(asyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_cur_task));
190190
if (self_in == cur_task) {
191191
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("can't cancel self"));
192192
}
@@ -195,7 +195,7 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) {
195195
self = MP_OBJ_TO_PTR(self->data);
196196
}
197197

198-
mp_obj_t _task_queue = mp_obj_dict_get(uasyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR__task_queue));
198+
mp_obj_t _task_queue = mp_obj_dict_get(asyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR__task_queue));
199199

200200
// Reschedule Task as a cancelled task.
201201
mp_obj_t dest[3];
@@ -218,7 +218,7 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) {
218218
task_queue_push(2, dest);
219219
}
220220

221-
self->data = mp_obj_dict_get(uasyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_CancelledError));
221+
self->data = mp_obj_dict_get(asyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_CancelledError));
222222

223223
return mp_const_true;
224224
}
@@ -278,7 +278,7 @@ STATIC mp_obj_t task_iternext(mp_obj_t self_in) {
278278
nlr_raise(self->data);
279279
} else {
280280
// Put calling task on waiting queue.
281-
mp_obj_t cur_task = mp_obj_dict_get(uasyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_cur_task));
281+
mp_obj_t cur_task = mp_obj_dict_get(asyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_cur_task));
282282
mp_obj_t args[2] = { self->state, cur_task };
283283
task_queue_push(2, args);
284284
// Set calling task's data to this task that it waits on, to double-link it.
@@ -302,20 +302,20 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
302302
);
303303

304304
/******************************************************************************/
305-
// C-level uasyncio module
305+
// C-level asyncio module
306306

307-
STATIC const mp_rom_map_elem_t mp_module_uasyncio_globals_table[] = {
308-
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__uasyncio) },
307+
STATIC const mp_rom_map_elem_t mp_module_asyncio_globals_table[] = {
308+
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__asyncio) },
309309
{ MP_ROM_QSTR(MP_QSTR_TaskQueue), MP_ROM_PTR(&task_queue_type) },
310310
{ MP_ROM_QSTR(MP_QSTR_Task), MP_ROM_PTR(&task_type) },
311311
};
312-
STATIC MP_DEFINE_CONST_DICT(mp_module_uasyncio_globals, mp_module_uasyncio_globals_table);
312+
STATIC MP_DEFINE_CONST_DICT(mp_module_asyncio_globals, mp_module_asyncio_globals_table);
313313

314-
const mp_obj_module_t mp_module_uasyncio = {
314+
const mp_obj_module_t mp_module_asyncio = {
315315
.base = { &mp_type_module },
316-
.globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals,
316+
.globals = (mp_obj_dict_t *)&mp_module_asyncio_globals,
317317
};
318318

319-
MP_REGISTER_MODULE(MP_QSTR__uasyncio, mp_module_uasyncio);
319+
MP_REGISTER_MODULE(MP_QSTR__asyncio, mp_module_asyncio);
320320

321-
#endif // MICROPY_PY_UASYNCIO
321+
#endif // MICROPY_PY_ASYNCIO

ports/esp32/boards/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
freeze("$(PORT_DIR)/modules")
2-
include("$(MPY_DIR)/extmod/uasyncio")
2+
include("$(MPY_DIR)/extmod/asyncio")
33

44
# Useful networking-related packages.
55
require("bundle-networking")

ports/esp8266/boards/GENERIC/manifest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# base modules
22
include("$(PORT_DIR)/boards/manifest.py")
33

4-
# uasyncio
5-
include("$(MPY_DIR)/extmod/uasyncio")
4+
# asyncio
5+
include("$(MPY_DIR)/extmod/asyncio")
66

77
# drivers
88
require("ssd1306")

ports/esp8266/boards/GENERIC_1M/mpconfigboard.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313

1414
#define MICROPY_PY_FSTRINGS (0)
1515
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
16-
#define MICROPY_PY_UASYNCIO (0)
16+
#define MICROPY_PY_ASYNCIO (0)
1717
#define MICROPY_PY_CRYPTOLIB (1)

ports/esp8266/boards/GENERIC_512K/mpconfigboard.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
#define MICROPY_PY_ALL_SPECIAL_METHODS (0)
99
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
1010
#define MICROPY_PY_SYS_STDIO_BUFFER (0)
11-
#define MICROPY_PY_UASYNCIO (0)
11+
#define MICROPY_PY_ASYNCIO (0)
1212
#define MICROPY_PY_RE_SUB (0)
1313
#define MICROPY_PY_FRAMEBUF (0)

ports/mimxrt/boards/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
freeze("$(PORT_DIR)/modules")
2-
include("$(MPY_DIR)/extmod/uasyncio")
2+
include("$(MPY_DIR)/extmod/asyncio")
33
require("onewire")
44
require("ds18x20")
55
require("dht")

ports/nrf/modules/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
module("_mkfs.py", base_path="$(PORT_DIR)/modules/scripts", opt=3)
2-
include("$(MPY_DIR)/extmod/uasyncio")
2+
include("$(MPY_DIR)/extmod/asyncio")

ports/renesas-ra/boards/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include("$(MPY_DIR)/extmod/uasyncio")
1+
include("$(MPY_DIR)/extmod/asyncio")
22
require("dht")
33
require("onewire")
44
require("sdcard")

ports/rp2/boards/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
freeze("$(PORT_DIR)/modules")
2-
include("$(MPY_DIR)/extmod/uasyncio")
2+
include("$(MPY_DIR)/extmod/asyncio")
33
require("onewire")
44
require("ds18x20")
55
require("dht")

ports/samd/mcu/samd51/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include("$(PORT_DIR)/boards/manifest.py")
2-
include("$(MPY_DIR)/extmod/uasyncio")
2+
include("$(MPY_DIR)/extmod/asyncio")
33
require("onewire")
44
require("ds18x20")
55
require("dht")

ports/samd/mpconfigport.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
#define MICROPY_PY_HEAPQ (1)
9393
#define MICROPY_PY_RANDOM (1)
9494
#define MICROPY_PY_ZLIB (1)
95-
#define MICROPY_PY_UASYNCIO (1)
95+
#define MICROPY_PY_ASYNCIO (1)
9696
#define MICROPY_PY_MACHINE_RTC (1)
9797
#ifndef MICROPY_PY_MACHINE_ADC
9898
#define MICROPY_PY_MACHINE_ADC (1)

ports/stm32/boards/NUCLEO_G474RE/mpconfigboard.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define MICROPY_HW_HAS_SWITCH (1)
1010
#define MICROPY_HW_HAS_FLASH (0) // QSPI extflash not mounted
1111

12-
#define MICROPY_PY_UASYNCIO (0)
12+
#define MICROPY_PY_ASYNCIO (0)
1313
#define MICROPY_PY_ZLIB (0)
1414
#define MICROPY_PY_BINASCII (0)
1515
#define MICROPY_PY_HASHLIB (0)

ports/stm32/boards/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include("$(MPY_DIR)/extmod/uasyncio")
1+
include("$(MPY_DIR)/extmod/asyncio")
22

33
require("dht")
44
require("onewire")
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include("$(PORT_DIR)/variants/manifest.py")
22

3-
include("$(MPY_DIR)/extmod/uasyncio")
3+
include("$(MPY_DIR)/extmod/asyncio")

ports/windows/msvc/sources.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PyExtModSource Include="$(PyBaseDir)extmod\machine_pinbase.c" />
88
<PyExtModSource Include="$(PyBaseDir)extmod\machine_pulse.c" />
99
<PyExtModSource Include="$(PyBaseDir)extmod\machine_signal.c" />
10-
<PyExtModSource Include="$(PyBaseDir)extmod\moduasyncio.c" />
10+
<PyExtModSource Include="$(PyBaseDir)extmod\modasyncio.c" />
1111
<PyExtModSource Include="$(PyBaseDir)extmod\modbinascii.c" />
1212
<PyExtModSource Include="$(PyBaseDir)extmod\moductypes.c" />
1313
<PyExtModSource Include="$(PyBaseDir)extmod\modhashlib.c" />
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
include("$(PORT_DIR)/variants/manifest.py")
2-
include("$(MPY_DIR)/extmod/uasyncio")
2+
include("$(MPY_DIR)/extmod/asyncio")

ports/windows/variants/dev/mpconfigvariant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
#define MICROPY_PY_BUILTINS_SLICE_INDICES (1)
3939
#define MICROPY_PY_SELECT (1)
4040

41-
#ifndef MICROPY_PY_UASYNCIO
42-
#define MICROPY_PY_UASYNCIO (1)
41+
#ifndef MICROPY_PY_ASYNCIO
42+
#define MICROPY_PY_ASYNCIO (1)
4343
#endif

py/mpconfig.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1541,8 +1541,8 @@ typedef double mp_float_t;
15411541

15421542
// Extended modules
15431543

1544-
#ifndef MICROPY_PY_UASYNCIO
1545-
#define MICROPY_PY_UASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
1544+
#ifndef MICROPY_PY_ASYNCIO
1545+
#define MICROPY_PY_ASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
15461546
#endif
15471547

15481548
#ifndef MICROPY_PY_UCTYPES

0 commit comments

Comments
 (0)