summaryrefslogtreecommitdiff
path: root/extmod/asyncio/__init__.py
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2023-06-08 15:51:50 +1000
committerDamien George <damien@micropython.org>2023-06-19 17:33:03 +1000
commit2fbc08c462e247e7f78460783c9a07c76c5b762e (patch)
treecfda4eb3b04a6cc281fb0ea668a15b6216353c16 /extmod/asyncio/__init__.py
parented962f1f233eb74edf2cee83dc488d3cac5e02ee (diff)
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>
Diffstat (limited to 'extmod/asyncio/__init__.py')
-rw-r--r--extmod/asyncio/__init__.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/extmod/asyncio/__init__.py b/extmod/asyncio/__init__.py
new file mode 100644
index 000000000..1f83750c5
--- /dev/null
+++ b/extmod/asyncio/__init__.py
@@ -0,0 +1,31 @@
+# MicroPython asyncio module
+# MIT license; Copyright (c) 2019 Damien P. George
+
+from .core import *
+
+__version__ = (3, 0, 0)
+
+_attrs = {
+ "wait_for": "funcs",
+ "wait_for_ms": "funcs",
+ "gather": "funcs",
+ "Event": "event",
+ "ThreadSafeFlag": "event",
+ "Lock": "lock",
+ "open_connection": "stream",
+ "start_server": "stream",
+ "StreamReader": "stream",
+ "StreamWriter": "stream",
+}
+
+
+# Lazy loader, effectively does:
+# global attr
+# from .mod import attr
+def __getattr__(attr):
+ mod = _attrs.get(attr, None)
+ if mod is None:
+ raise AttributeError(attr)
+ value = getattr(__import__(mod, None, None, True, 1), attr)
+ globals()[attr] = value
+ return value