uasyncio error using Message class

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
angel0ne
Posts: 7
Joined: Sun Mar 21, 2021 4:33 pm

uasyncio error using Message class

Post by angel0ne » Tue Apr 06, 2021 5:57 am

I'm running Micropython v1.14 and uasyncio v3.0.0 on ESP32 and I would like to use the Message class.
I copied the primitives directory tree and its contents to the ESP32's filesystem as reported here: https://github.com/peterhinch/micropyth ... primitives

but when I try to import the Message class like in this example:

Code: Select all

import uasyncio as asyncio
from primitives.message import Message

async def waiter(msg):
    print('Waiting for message')
    res = await msg
    print('waiter got', res)
    msg.clear()

async def main():
    msg = Message()
    asyncio.create_task(waiter(msg))
    await asyncio.sleep(1)
    msg.set('Hello')  # Optional arg
    await asyncio.sleep(1)

asyncio.run(main())
I got the following error:

Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "primitives/message.py", line 20, in <module>
File "uasyncio/__init__.py", line 1, in __getattr__
AttributeError: ThreadSafeFlag

Anyone can help me? Many thanks

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uasyncio error using Message class

Post by pythoncoder » Tue Apr 06, 2021 6:25 am

You need to run the latest daily build of firmware: ThreadSafeFlag will be supported in release build 1.15.
Peter Hinch
Index to my micropython libraries.

angel0ne
Posts: 7
Joined: Sun Mar 21, 2021 4:33 pm

Re: uasyncio error using Message class

Post by angel0ne » Tue Apr 06, 2021 6:31 am

pythoncoder wrote:
Tue Apr 06, 2021 6:25 am
You need to run the latest daily build of firmware: ThreadSafeFlag will be supported in release build 1.15.
Thanks Peter, how can I install v1.15?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uasyncio error using Message class

Post by pythoncoder » Tue Apr 06, 2021 6:35 am

V1.15 is due for release later this month. Use the latest daily build.

This requirement is stated in the tutorial.
Peter Hinch
Index to my micropython libraries.

Post Reply