When trying to use asyncio.run on the unix port I get the error
AttributeError: 'module' object has no attribute 'run'
When running the same thing on the esp32 everything works as expected. I have attached the very simple demo program on which I can check this. Any idea why this is the case?
asyncio.run on unix port
asyncio.run on unix port
- Attachments
-
- asyncio.png (15.08 KiB) Viewed 2576 times
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: asyncio.run on unix port
That script works here. Please check if you have uasyncio V3:
should produce (3, 0, 0). If it produces an exception you have V2, in which case you need to get the latest sources and rebuild the Unix port.
Code: Select all
import uasyncio
print(uasyncio.__version__)
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: asyncio.run on unix port
Thanks Pete,
That's weird! I built the Unix version and the ESP32 from the same MicroPython sources. The ESP32 version works, the Unix version seems to use uasyncio V2.
Just to be sure I cloned MicroPython from github just now and rebuilt the Unix version. Do I have to give an option to make to get uasyncio V3?
That's weird! I built the Unix version and the ESP32 from the same MicroPython sources. The ESP32 version works, the Unix version seems to use uasyncio V2.
Just to be sure I cloned MicroPython from github just now and rebuilt the Unix version. Do I have to give an option to make to get uasyncio V3?
- Attachments
-
- uasyncio.png (34.12 KiB) Viewed 2552 times
Re: asyncio.run on unix port
Hi Pete,
Your answer pointed me into the right direction: The standard version of unix micropython uses uasyncio V2 (I think this should be changed!). If I build the "dev" version, I get V3.
Your answer pointed me into the right direction: The standard version of unix micropython uses uasyncio V2 (I think this should be changed!). If I build the "dev" version, I get V3.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Now I'm foxed...
Now it's me who's baffled. I've just fetched the latest sources and rebuilt. My build script does make clean then make in the unix directory. Here is the outcome:
My unix build has uasyncio V3. So why do our results differ?
[EDITED]
Looking at my build, uasyncio is not being built as frozen bytecode: I think we both know the reason having studied the manifests and makefile.
What is happening is that the module is running as Python code. The task queue has C and Python implementations, so uasyncio can run without frozen code. I proved that it is running as Python code by renaming extmod/uasyncio.core.py and the import duly broke.
The things that puzzle me are:
Code: Select all
MicroPython v1.13-107-g18518e26a-dirty on 2020-10-18; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import uasyncio
>>> uasyncio.__version__
(3, 0, 0)
>>>
[EDITED]
Looking at my build, uasyncio is not being built as frozen bytecode: I think we both know the reason having studied the manifests and makefile.
What is happening is that the module is running as Python code. The task queue has C and Python implementations, so uasyncio can run without frozen code. I proved that it is running as Python code by renaming extmod/uasyncio.core.py and the import duly broke.
The things that puzzle me are:
- How is my build finding that directory.
- Why is yours not doing so.
Code: Select all
['', '/home/adminpete/.micropython/lib', '/usr/lib/micropython']
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: asyncio.run on unix port
My guess is that uraich has previously installed v2 from micropython-lib and it's in ~/.micropython/lib and being used preferentially over the frozen v3 code.
Re: asyncio.run on unix port
Hi jimmo
You are perfectly right. In fact uasyncio is not included in the standard unix micropython at all and my micropython found it in $HOME/.micropython, which was from the micropython-lib. The dev variant includes uasyncio and it include V3 of it.
You are perfectly right. In fact uasyncio is not included in the standard unix micropython at all and my micropython found it in $HOME/.micropython, which was from the micropython-lib. The dev variant includes uasyncio and it include V3 of it.