英文:
Why does uasyncio module in micropython doesn't have any "run" function?
问题
I am using an ESP8266 board with micropython.
I tried to use asyncio, but it doesn't work and says me that:
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
File "<stdin>", line 7, in main
AttributeError: 'module' object has no attribute 'run'
I took a look about what does uasyncio contains and I got this:
>>> import uasyncio as asyncio
>>> asyncio.
__class__ __name__ __path__ DEBUG
log select sleep sleep_ms
time ucollections uerrno utimeq
type_gen set_debug CancelledError TimeoutError
EventLoop SysCall SysCall1 StopLoop
IORead IOWrite IOReadDone IOWriteDone
get_event_loop SleepMs cancel TimeoutObj
wait_for_ms wait_for coroutine ensure_future
Task _socket PollEventLoop StreamReader
StreamWriter open_connection start_server
uasyncio core
After some researches, I have found in this documentation that uasyncio is supposed to get functions like new_event_loop()
, run
, etc... that I absolutely don't have there...
There is my script:
from robot import *
import uasyncio as asyncio
def main(args):
robot = MicroportalRobot("robotName", "serverAddr", 8266)
asyncio.run(robot.main())
if __name__ == "__main__":
main([])
Why?
英文:
I am using an ESP8266 board with micropython.
I tried to use asyncio, but it doesn't work and says me that :
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
File "<stdin>", line 7, in main
AttributeError: 'module' object has no attribute 'run'
I took a look about what does uasyncio contains and I got this :
>>> import uasyncio as asyncio
>>> asyncio.
__class__ __name__ __path__ DEBUG
log select sleep sleep_ms
time ucollections uerrno utimeq
type_gen set_debug CancelledError TimeoutError
EventLoop SysCall SysCall1 StopLoop
IORead IOWrite IOReadDone IOWriteDone
get_event_loop SleepMs cancel TimeoutObj
wait_for_ms wait_for coroutine ensure_future
Task _socket PollEventLoop StreamReader
StreamWriter open_connection start_server
uasyncio core
After some researches, I have found in this documentation that uasyncio is supposed to get functions like new_event_loop()
, run
, etc... that I absolutely don't have there...
There is my script :
from robot import *
import uasyncio as asyncio
def main(args):
robot = MicroportalRobot("robotName", "serverAddr", 8266)
asyncio.run(robot.main())
if __name__ == "__main__":
main([])
Why?
答案1
得分: 1
你正在寻找的功能是uasyncio v3的一部分,作为micropython 1.13的一部分发布。您需要至少与1.13版本相同或更新的micropython版本才能使用它们。您的评论表明您使用的是micropython 1.11,这意味着您使用的是旧版本的v2 uasyncio实现,不具备这些功能。
您需要安装更新的micropython版本,或者继续使用uasyncio v2 API。
英文:
The features you're looking for are part of uasyncio v3, released as part of micropython 1.13. You need a micropython version at least as recent as 1.13 to use them. Your comments indicate you're on micropython 1.11, meaning you have the old v2 uasyncio implementation, which does not have these features.
You will need to install a more recent micropython build, or stick to the uasyncio v2 API.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论