Page 1 of 1

uasyncio error using Message class

Posted: Tue Apr 06, 2021 5:57 am
by angel0ne
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

Re: uasyncio error using Message class

Posted: Tue Apr 06, 2021 6:25 am
by pythoncoder
You need to run the latest daily build of firmware: ThreadSafeFlag will be supported in release build 1.15.

Re: uasyncio error using Message class

Posted: Tue Apr 06, 2021 6:31 am
by angel0ne
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?

Re: uasyncio error using Message class

Posted: Tue Apr 06, 2021 6:35 am
by pythoncoder
V1.15 is due for release later this month. Use the latest daily build.

This requirement is stated in the tutorial.