Asyncio in uPython 1.14 has not "run"???

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
enzo
Posts: 40
Joined: Thu Jun 11, 2020 1:03 am

Re: Asyncio in uPython 1.14 has not "run"???

Post by enzo » Sun Feb 07, 2021 8:27 pm

enzo wrote:
Sun Feb 07, 2021 7:57 pm
enzo wrote:
Sun Feb 07, 2021 7:48 pm
kevinkk525 wrote:
Sun Feb 07, 2021 7:27 pm
that's right. Looks like you're doing it correctly.
You could try the daily firmware until we can find out whats happening (assuming the daily firmware has uasyncio v3 which I assume it does).
I'll give it a try and let you know.
Same problem with last unstable:

Code: Select all

MicroPython v1.14-9-g9dedcf122 on 2021-02-07; ESP module (1M) with ESP8266
Type "help()" for more information.
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 20, in <module>
AttributeError: 'module' object has no attribute 'run'

Code: Select all

>>> import uasyncio
>>> dir(uasyncio)
['__class__', '__name__', '__path__', 'log', 'select', 'sleep', 'sleep_ms', 'time', 'ucollections', 'uerrno', 'utimeq', 'DEBUG', 'uasyncio', '_socket', 'core', 'set_debug', 'PollEventLoop', 'EventLoop', 'StreamReader', 'IORead', 'IOReadDone', 'StreamWriter', 'IOWrite', 'IOWriteDone', 'open_connection', 'start_server', 'type_gen', 'CancelledError', 'TimeoutError', 'SysCall1', 'SleepMs', 'StopLoop', 'SysCall', 'get_event_loop', 'cancel', 'TimeoutObj', 'wait_for_ms', 'wait_for', 'coroutine', 'ensure_future', 'Task']
>>> 
I see there's a "uasyncio" method in "uasyncio" module so I tried:

Code: Select all

>>> uasyncio.uasyncio.run()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'run'
>>> 
but no success.
One more thing: uasyncio isn't in the MicroPython 1.14 I downloaded: I need to install it:

Code: Select all

>>> upip.install("uasyncio")
Installing to: /lib/
Warning: micropython.org SSL certificate is not validated
Installing uasyncio 2.0 from https://micropython.org/pi/uasyncio/uasyncio-2.0.tar.gz
Installing micropython-uasyncio.core 2.0 from https://micropython.org/pi/uasyncio.core/uasyncio.core-2.0.tar.gz
Maybe this one is faulty? And why it isn't in the standard 1.13 and 1.14 libraries?

kevinkk525
Posts: 925
Joined: Sat Feb 03, 2018 7:02 pm

Re: Asyncio in uPython 1.14 has not "run"???

Post by kevinkk525 » Sun Feb 07, 2021 10:12 pm

Uasyncio needs to be part of the firmware.
If you install it from upip, you get the old version.

Did you download the firmware for the modules with 2MB or more? Because this one should have uasyncio, the smaller ones don't.
I quickly checked the repo and it should have uasyncio. I don't have time anymore today but tomorrow I can download a firmware and flash it on my esp8266 to confirm.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

enzo
Posts: 40
Joined: Thu Jun 11, 2020 1:03 am

Re: Asyncio in uPython 1.14 has not "run"???

Post by enzo » Sun Feb 07, 2021 11:19 pm

kevinkk525 wrote:
Sun Feb 07, 2021 10:12 pm
Uasyncio needs to be part of the firmware.
If you install it from upip, you get the old version.

Did you download the firmware for the modules with 2MB or more? Because this one should have uasyncio, the smaller ones don't.
I quickly checked the repo and it should have uasyncio. I don't have time anymore today but tomorrow I can download a firmware and flash it on my esp8266 to confirm.
I downloaded the one I wrote in my previous post: it's for 1MB because I'm working with ESP8266 which have a memory of 1MB.
I didn't find anywhere that uasyncio only works for 2MB or more.
Why is it in the 1MB firmware if it can't be called?

kevinkk525
Posts: 925
Joined: Sat Feb 03, 2018 7:02 pm

Re: Asyncio in uPython 1.14 has not "run"???

Post by kevinkk525 » Mon Feb 08, 2021 5:55 am

Oh I must have missed the information that you use a 1MB firmware. But interesting that the old uasyncio is part of that firmware, that does indeed make no sense at all.

So if you want to use the new uasyncio with the 1MB module, you need to build the firmware yourself. you can take a look at my scripts to build a 1MB firmware (which I modified to allow for a big firmware with a small filesystem): https://github.com/kevinkk525/pysmartno ... ls/esp8266
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

enzo
Posts: 40
Joined: Thu Jun 11, 2020 1:03 am

Re: Asyncio in uPython 1.14 has not "run"???

Post by enzo » Mon Feb 08, 2021 9:43 pm

kevinkk525 wrote:
Mon Feb 08, 2021 5:55 am
Oh I must have missed the information that you use a 1MB firmware. But interesting that the old uasyncio is part of that firmware, that does indeed make no sense at all.

So if you want to use the new uasyncio with the 1MB module, you need to build the firmware yourself. you can take a look at my scripts to build a 1MB firmware (which I modified to allow for a big firmware with a small filesystem): https://github.com/kevinkk525/pysmartno ... ls/esp8266
Thanks Kevin, now I'm in a rush for this project and still many things are left.
I can't stop and study how to build the MicroPython by myself (although I'd like to understand that!), I'm afraid my only chance is using a >= 2MB module.

Damien
Site Admin
Posts: 642
Joined: Mon Dec 09, 2013 5:02 pm

Re: Asyncio in uPython 1.14 has not "run"???

Post by Damien » Tue Feb 09, 2021 1:02 am

esp8266 builds for 1M modules do not have uasyncio included in them (maybe we can add it to them, not sure if there's enough space left on the 1M builds).

The reason you can import uasyncio on your board is because it's been installed via upip and resides in the filesystem.

I've now updated upip so that it installs the latest v3 of uasyncio. So that the esp8266 can download it with a small TLS buffer size, the distribution is split into uasyncio and uasyncio.extra. So install it via:

Code: Select all

import upip
upip.install('uasyncio')
upip.install('uasyncio.extra')
uasyncio.extra contains Event, Lock, wait_for and gather. It's only needed if you want those functions/classes.

kevinkk525
Posts: 925
Joined: Sat Feb 03, 2018 7:02 pm

Re: Asyncio in uPython 1.14 has not "run"???

Post by kevinkk525 » Tue Feb 09, 2021 6:00 am

That's good news.
However, personally any module without uasyncio is unusable to me and the 1M build should have enough space left for uasyncio even if other modules need to go or the flash side reduced.
In the forum we often refer to using uasyncio for programming, I think it is a core module that should be available everywhere. Even more than modules like btree, who are (as far as I can tell) are not widely used.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

Damien
Site Admin
Posts: 642
Joined: Mon Dec 09, 2013 5:02 pm

Re: Asyncio in uPython 1.14 has not "run"???

Post by Damien » Tue Feb 09, 2021 7:45 am

kevinkk525 wrote:
Tue Feb 09, 2021 6:00 am
In the forum we often refer to using uasyncio for programming, I think it is a core module that should be available everywhere. Even more than modules like btree, who are (as far as I can tell) are not widely used.
Yep, I agree. Might be a good idea to revisit the esp8266 1M board definition to see if we can adjust the available modules, so uasyncio can be made available.

enzo
Posts: 40
Joined: Thu Jun 11, 2020 1:03 am

Re: Asyncio in uPython 1.14 has not "run"???

Post by enzo » Mon Feb 15, 2021 12:51 am

Damien wrote:
Tue Feb 09, 2021 7:45 am
kevinkk525 wrote:
Tue Feb 09, 2021 6:00 am
In the forum we often refer to using uasyncio for programming, I think it is a core module that should be available everywhere. Even more than modules like btree, who are (as far as I can tell) are not widely used.
Yep, I agree. Might be a good idea to revisit the esp8266 1M board definition to see if we can adjust the available modules, so uasyncio can be made available.
That would be great!!!

Post Reply