Browse Source

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 <jim.mussared@gmail.com>
pull/11740/head
Jim Mussared 1 year ago
committed by Damien George
parent
commit
2fbc08c462
  1. 2
      extmod/asyncio/__init__.py
  2. 4
      extmod/asyncio/core.py
  3. 2
      extmod/asyncio/event.py
  4. 2
      extmod/asyncio/funcs.py
  5. 2
      extmod/asyncio/lock.py
  6. 2
      extmod/asyncio/manifest.py
  7. 2
      extmod/asyncio/stream.py
  8. 2
      extmod/asyncio/task.py
  9. 2
      extmod/extmod.cmake
  10. 2
      extmod/extmod.mk
  11. 32
      extmod/modasyncio.c
  12. 2
      ports/esp32/boards/manifest.py
  13. 4
      ports/esp8266/boards/GENERIC/manifest.py
  14. 2
      ports/esp8266/boards/GENERIC_1M/mpconfigboard.h
  15. 2
      ports/esp8266/boards/GENERIC_512K/mpconfigboard.h
  16. 2
      ports/mimxrt/boards/manifest.py
  17. 2
      ports/nrf/modules/manifest.py
  18. 2
      ports/renesas-ra/boards/manifest.py
  19. 2
      ports/rp2/boards/manifest.py
  20. 2
      ports/samd/mcu/samd51/manifest.py
  21. 2
      ports/samd/mpconfigport.h
  22. 2
      ports/stm32/boards/NUCLEO_G474RE/mpconfigboard.h
  23. 2
      ports/stm32/boards/manifest.py
  24. 2
      ports/unix/variants/standard/manifest.py
  25. 2
      ports/windows/msvc/sources.props
  26. 2
      ports/windows/variants/dev/manifest.py
  27. 4
      ports/windows/variants/dev/mpconfigvariant.h
  28. 4
      py/mpconfig.h

2
extmod/uasyncio/__init__.py → extmod/asyncio/__init__.py

@ -1,4 +1,4 @@
# MicroPython uasyncio module # MicroPython asyncio module
# MIT license; Copyright (c) 2019 Damien P. George # MIT license; Copyright (c) 2019 Damien P. George
from .core import * from .core import *

4
extmod/uasyncio/core.py → extmod/asyncio/core.py

@ -1,4 +1,4 @@
# MicroPython uasyncio module # MicroPython asyncio module
# MIT license; Copyright (c) 2019 Damien P. George # MIT license; Copyright (c) 2019 Damien P. George
from time import ticks_ms as ticks, ticks_diff, ticks_add from time import ticks_ms as ticks, ticks_diff, ticks_add
@ -6,7 +6,7 @@ import sys, select
# Import TaskQueue and Task, preferring built-in C code over Python code # Import TaskQueue and Task, preferring built-in C code over Python code
try: try:
from _uasyncio import TaskQueue, Task from _asyncio import TaskQueue, Task
except: except:
from .task import TaskQueue, Task from .task import TaskQueue, Task

2
extmod/uasyncio/event.py → extmod/asyncio/event.py

@ -1,4 +1,4 @@
# MicroPython uasyncio module # MicroPython asyncio module
# MIT license; Copyright (c) 2019-2020 Damien P. George # MIT license; Copyright (c) 2019-2020 Damien P. George
from . import core from . import core

2
extmod/uasyncio/funcs.py → extmod/asyncio/funcs.py

@ -1,4 +1,4 @@
# MicroPython uasyncio module # MicroPython asyncio module
# MIT license; Copyright (c) 2019-2022 Damien P. George # MIT license; Copyright (c) 2019-2022 Damien P. George
from . import core from . import core

2
extmod/uasyncio/lock.py → extmod/asyncio/lock.py

@ -1,4 +1,4 @@
# MicroPython uasyncio module # MicroPython asyncio module
# MIT license; Copyright (c) 2019-2020 Damien P. George # MIT license; Copyright (c) 2019-2020 Damien P. George
from . import core from . import core

2
extmod/uasyncio/manifest.py → extmod/asyncio/manifest.py

@ -1,7 +1,7 @@
# This list of package files doesn't include task.py because that's provided # This list of package files doesn't include task.py because that's provided
# by the C module. # by the C module.
package( package(
"uasyncio", "asyncio",
( (
"__init__.py", "__init__.py",
"core.py", "core.py",

2
extmod/uasyncio/stream.py → extmod/asyncio/stream.py

@ -1,4 +1,4 @@
# MicroPython uasyncio module # MicroPython asyncio module
# MIT license; Copyright (c) 2019-2020 Damien P. George # MIT license; Copyright (c) 2019-2020 Damien P. George
from . import core from . import core

2
extmod/uasyncio/task.py → extmod/asyncio/task.py

@ -1,4 +1,4 @@
# MicroPython uasyncio module # MicroPython asyncio module
# MIT license; Copyright (c) 2019-2020 Damien P. George # MIT license; Copyright (c) 2019-2020 Damien P. George
# This file contains the core TaskQueue based on a pairing heap, and the core Task class. # This file contains the core TaskQueue based on a pairing heap, and the core Task class.

2
extmod/extmod.cmake

@ -19,7 +19,7 @@ set(MICROPY_SOURCE_EXTMOD
${MICROPY_EXTMOD_DIR}/modlwip.c ${MICROPY_EXTMOD_DIR}/modlwip.c
${MICROPY_EXTMOD_DIR}/modnetwork.c ${MICROPY_EXTMOD_DIR}/modnetwork.c
${MICROPY_EXTMOD_DIR}/modonewire.c ${MICROPY_EXTMOD_DIR}/modonewire.c
${MICROPY_EXTMOD_DIR}/moduasyncio.c ${MICROPY_EXTMOD_DIR}/modasyncio.c
${MICROPY_EXTMOD_DIR}/modbinascii.c ${MICROPY_EXTMOD_DIR}/modbinascii.c
${MICROPY_EXTMOD_DIR}/modcryptolib.c ${MICROPY_EXTMOD_DIR}/modcryptolib.c
${MICROPY_EXTMOD_DIR}/moductypes.c ${MICROPY_EXTMOD_DIR}/moductypes.c

2
extmod/extmod.mk

@ -11,6 +11,7 @@ SRC_EXTMOD_C += \
extmod/machine_signal.c \ extmod/machine_signal.c \
extmod/machine_spi.c \ extmod/machine_spi.c \
extmod/machine_timer.c \ extmod/machine_timer.c \
extmod/modasyncio.c \
extmod/modbinascii.c \ extmod/modbinascii.c \
extmod/modbluetooth.c \ extmod/modbluetooth.c \
extmod/modbtree.c \ extmod/modbtree.c \
@ -31,7 +32,6 @@ SRC_EXTMOD_C += \
extmod/modssl_axtls.c \ extmod/modssl_axtls.c \
extmod/modssl_mbedtls.c \ extmod/modssl_mbedtls.c \
extmod/modtime.c \ extmod/modtime.c \
extmod/moduasyncio.c \
extmod/moductypes.c \ extmod/moductypes.c \
extmod/modwebrepl.c \ extmod/modwebrepl.c \
extmod/modwebsocket.c \ extmod/modwebsocket.c \

32
extmod/moduasyncio.c → extmod/modasyncio.c

@ -29,7 +29,7 @@
#include "py/pairheap.h" #include "py/pairheap.h"
#include "py/mphal.h" #include "py/mphal.h"
#if MICROPY_PY_UASYNCIO #if MICROPY_PY_ASYNCIO
// Used when task cannot be guaranteed to be non-NULL. // Used when task cannot be guaranteed to be non-NULL.
#define TASK_PAIRHEAP(task) ((task) ? &(task)->pairheap : NULL) #define TASK_PAIRHEAP(task) ((task) ? &(task)->pairheap : NULL)
@ -155,8 +155,8 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
/******************************************************************************/ /******************************************************************************/
// Task class // Task class
// This is the core uasyncio context with cur_task, _task_queue and CancelledError. // This is the core asyncio context with cur_task, _task_queue and CancelledError.
STATIC mp_obj_t uasyncio_context = MP_OBJ_NULL; STATIC mp_obj_t asyncio_context = MP_OBJ_NULL;
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) { 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) {
mp_arg_check_num(n_args, n_kw, 1, 2, false); 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
self->state = TASK_STATE_RUNNING_NOT_WAITED_ON; self->state = TASK_STATE_RUNNING_NOT_WAITED_ON;
self->ph_key = MP_OBJ_NEW_SMALL_INT(0); self->ph_key = MP_OBJ_NEW_SMALL_INT(0);
if (n_args == 2) { if (n_args == 2) {
uasyncio_context = args[1]; asyncio_context = args[1];
} }
return MP_OBJ_FROM_PTR(self); return MP_OBJ_FROM_PTR(self);
} }
@ -186,7 +186,7 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) {
return mp_const_false; return mp_const_false;
} }
// Can't cancel self (not supported yet). // Can't cancel self (not supported yet).
mp_obj_t cur_task = mp_obj_dict_get(uasyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_cur_task)); mp_obj_t cur_task = mp_obj_dict_get(asyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_cur_task));
if (self_in == cur_task) { if (self_in == cur_task) {
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("can't cancel self")); mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("can't cancel self"));
} }
@ -195,7 +195,7 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) {
self = MP_OBJ_TO_PTR(self->data); self = MP_OBJ_TO_PTR(self->data);
} }
mp_obj_t _task_queue = mp_obj_dict_get(uasyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR__task_queue)); mp_obj_t _task_queue = mp_obj_dict_get(asyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR__task_queue));
// Reschedule Task as a cancelled task. // Reschedule Task as a cancelled task.
mp_obj_t dest[3]; mp_obj_t dest[3];
@ -218,7 +218,7 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) {
task_queue_push(2, dest); task_queue_push(2, dest);
} }
self->data = mp_obj_dict_get(uasyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_CancelledError)); self->data = mp_obj_dict_get(asyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_CancelledError));
return mp_const_true; return mp_const_true;
} }
@ -278,7 +278,7 @@ STATIC mp_obj_t task_iternext(mp_obj_t self_in) {
nlr_raise(self->data); nlr_raise(self->data);
} else { } else {
// Put calling task on waiting queue. // Put calling task on waiting queue.
mp_obj_t cur_task = mp_obj_dict_get(uasyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_cur_task)); mp_obj_t cur_task = mp_obj_dict_get(asyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_cur_task));
mp_obj_t args[2] = { self->state, cur_task }; mp_obj_t args[2] = { self->state, cur_task };
task_queue_push(2, args); task_queue_push(2, args);
// Set calling task's data to this task that it waits on, to double-link it. // 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(
); );
/******************************************************************************/ /******************************************************************************/
// C-level uasyncio module // C-level asyncio module
STATIC const mp_rom_map_elem_t mp_module_uasyncio_globals_table[] = { STATIC const mp_rom_map_elem_t mp_module_asyncio_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__uasyncio) }, { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__asyncio) },
{ MP_ROM_QSTR(MP_QSTR_TaskQueue), MP_ROM_PTR(&task_queue_type) }, { MP_ROM_QSTR(MP_QSTR_TaskQueue), MP_ROM_PTR(&task_queue_type) },
{ MP_ROM_QSTR(MP_QSTR_Task), MP_ROM_PTR(&task_type) }, { MP_ROM_QSTR(MP_QSTR_Task), MP_ROM_PTR(&task_type) },
}; };
STATIC MP_DEFINE_CONST_DICT(mp_module_uasyncio_globals, mp_module_uasyncio_globals_table); STATIC MP_DEFINE_CONST_DICT(mp_module_asyncio_globals, mp_module_asyncio_globals_table);
const mp_obj_module_t mp_module_uasyncio = { const mp_obj_module_t mp_module_asyncio = {
.base = { &mp_type_module }, .base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals, .globals = (mp_obj_dict_t *)&mp_module_asyncio_globals,
}; };
MP_REGISTER_MODULE(MP_QSTR__uasyncio, mp_module_uasyncio); MP_REGISTER_MODULE(MP_QSTR__asyncio, mp_module_asyncio);
#endif // MICROPY_PY_UASYNCIO #endif // MICROPY_PY_ASYNCIO

2
ports/esp32/boards/manifest.py

@ -1,5 +1,5 @@
freeze("$(PORT_DIR)/modules") freeze("$(PORT_DIR)/modules")
include("$(MPY_DIR)/extmod/uasyncio") include("$(MPY_DIR)/extmod/asyncio")
# Useful networking-related packages. # Useful networking-related packages.
require("bundle-networking") require("bundle-networking")

4
ports/esp8266/boards/GENERIC/manifest.py

@ -1,8 +1,8 @@
# base modules # base modules
include("$(PORT_DIR)/boards/manifest.py") include("$(PORT_DIR)/boards/manifest.py")
# uasyncio # asyncio
include("$(MPY_DIR)/extmod/uasyncio") include("$(MPY_DIR)/extmod/asyncio")
# drivers # drivers
require("ssd1306") require("ssd1306")

2
ports/esp8266/boards/GENERIC_1M/mpconfigboard.h

@ -13,5 +13,5 @@
#define MICROPY_PY_FSTRINGS (0) #define MICROPY_PY_FSTRINGS (0)
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
#define MICROPY_PY_UASYNCIO (0) #define MICROPY_PY_ASYNCIO (0)
#define MICROPY_PY_CRYPTOLIB (1) #define MICROPY_PY_CRYPTOLIB (1)

2
ports/esp8266/boards/GENERIC_512K/mpconfigboard.h

@ -8,6 +8,6 @@
#define MICROPY_PY_ALL_SPECIAL_METHODS (0) #define MICROPY_PY_ALL_SPECIAL_METHODS (0)
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
#define MICROPY_PY_SYS_STDIO_BUFFER (0) #define MICROPY_PY_SYS_STDIO_BUFFER (0)
#define MICROPY_PY_UASYNCIO (0) #define MICROPY_PY_ASYNCIO (0)
#define MICROPY_PY_RE_SUB (0) #define MICROPY_PY_RE_SUB (0)
#define MICROPY_PY_FRAMEBUF (0) #define MICROPY_PY_FRAMEBUF (0)

2
ports/mimxrt/boards/manifest.py

@ -1,5 +1,5 @@
freeze("$(PORT_DIR)/modules") freeze("$(PORT_DIR)/modules")
include("$(MPY_DIR)/extmod/uasyncio") include("$(MPY_DIR)/extmod/asyncio")
require("onewire") require("onewire")
require("ds18x20") require("ds18x20")
require("dht") require("dht")

2
ports/nrf/modules/manifest.py

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

2
ports/renesas-ra/boards/manifest.py

@ -1,4 +1,4 @@
include("$(MPY_DIR)/extmod/uasyncio") include("$(MPY_DIR)/extmod/asyncio")
require("dht") require("dht")
require("onewire") require("onewire")
require("sdcard") require("sdcard")

2
ports/rp2/boards/manifest.py

@ -1,5 +1,5 @@
freeze("$(PORT_DIR)/modules") freeze("$(PORT_DIR)/modules")
include("$(MPY_DIR)/extmod/uasyncio") include("$(MPY_DIR)/extmod/asyncio")
require("onewire") require("onewire")
require("ds18x20") require("ds18x20")
require("dht") require("dht")

2
ports/samd/mcu/samd51/manifest.py

@ -1,5 +1,5 @@
include("$(PORT_DIR)/boards/manifest.py") include("$(PORT_DIR)/boards/manifest.py")
include("$(MPY_DIR)/extmod/uasyncio") include("$(MPY_DIR)/extmod/asyncio")
require("onewire") require("onewire")
require("ds18x20") require("ds18x20")
require("dht") require("dht")

2
ports/samd/mpconfigport.h

@ -92,7 +92,7 @@
#define MICROPY_PY_HEAPQ (1) #define MICROPY_PY_HEAPQ (1)
#define MICROPY_PY_RANDOM (1) #define MICROPY_PY_RANDOM (1)
#define MICROPY_PY_ZLIB (1) #define MICROPY_PY_ZLIB (1)
#define MICROPY_PY_UASYNCIO (1) #define MICROPY_PY_ASYNCIO (1)
#define MICROPY_PY_MACHINE_RTC (1) #define MICROPY_PY_MACHINE_RTC (1)
#ifndef MICROPY_PY_MACHINE_ADC #ifndef MICROPY_PY_MACHINE_ADC
#define MICROPY_PY_MACHINE_ADC (1) #define MICROPY_PY_MACHINE_ADC (1)

2
ports/stm32/boards/NUCLEO_G474RE/mpconfigboard.h

@ -9,7 +9,7 @@
#define MICROPY_HW_HAS_SWITCH (1) #define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (0) // QSPI extflash not mounted #define MICROPY_HW_HAS_FLASH (0) // QSPI extflash not mounted
#define MICROPY_PY_UASYNCIO (0) #define MICROPY_PY_ASYNCIO (0)
#define MICROPY_PY_ZLIB (0) #define MICROPY_PY_ZLIB (0)
#define MICROPY_PY_BINASCII (0) #define MICROPY_PY_BINASCII (0)
#define MICROPY_PY_HASHLIB (0) #define MICROPY_PY_HASHLIB (0)

2
ports/stm32/boards/manifest.py

@ -1,4 +1,4 @@
include("$(MPY_DIR)/extmod/uasyncio") include("$(MPY_DIR)/extmod/asyncio")
require("dht") require("dht")
require("onewire") require("onewire")

2
ports/unix/variants/standard/manifest.py

@ -1,3 +1,3 @@
include("$(PORT_DIR)/variants/manifest.py") include("$(PORT_DIR)/variants/manifest.py")
include("$(MPY_DIR)/extmod/uasyncio") include("$(MPY_DIR)/extmod/asyncio")

2
ports/windows/msvc/sources.props

@ -7,7 +7,7 @@
<PyExtModSource Include="$(PyBaseDir)extmod\machine_pinbase.c" /> <PyExtModSource Include="$(PyBaseDir)extmod\machine_pinbase.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\machine_pulse.c" /> <PyExtModSource Include="$(PyBaseDir)extmod\machine_pulse.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\machine_signal.c" /> <PyExtModSource Include="$(PyBaseDir)extmod\machine_signal.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\moduasyncio.c" /> <PyExtModSource Include="$(PyBaseDir)extmod\modasyncio.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\modbinascii.c" /> <PyExtModSource Include="$(PyBaseDir)extmod\modbinascii.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\moductypes.c" /> <PyExtModSource Include="$(PyBaseDir)extmod\moductypes.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\modhashlib.c" /> <PyExtModSource Include="$(PyBaseDir)extmod\modhashlib.c" />

2
ports/windows/variants/dev/manifest.py

@ -1,2 +1,2 @@
include("$(PORT_DIR)/variants/manifest.py") include("$(PORT_DIR)/variants/manifest.py")
include("$(MPY_DIR)/extmod/uasyncio") include("$(MPY_DIR)/extmod/asyncio")

4
ports/windows/variants/dev/mpconfigvariant.h

@ -38,6 +38,6 @@
#define MICROPY_PY_BUILTINS_SLICE_INDICES (1) #define MICROPY_PY_BUILTINS_SLICE_INDICES (1)
#define MICROPY_PY_SELECT (1) #define MICROPY_PY_SELECT (1)
#ifndef MICROPY_PY_UASYNCIO #ifndef MICROPY_PY_ASYNCIO
#define MICROPY_PY_UASYNCIO (1) #define MICROPY_PY_ASYNCIO (1)
#endif #endif

4
py/mpconfig.h

@ -1541,8 +1541,8 @@ typedef double mp_float_t;
// Extended modules // Extended modules
#ifndef MICROPY_PY_UASYNCIO #ifndef MICROPY_PY_ASYNCIO
#define MICROPY_PY_UASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #define MICROPY_PY_ASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
#endif #endif
#ifndef MICROPY_PY_UCTYPES #ifndef MICROPY_PY_UCTYPES

Loading…
Cancel
Save