2

I am in need to use some sort of thread-safe queue in micropython running on an ev3dev device.

I am trying by using the uasyncio module but although it seems to be recognizing the library correctly when I try to use the Queue I get strange behavior. Here is a sample of commands executed in an interactive micropython session:

MicroPython v1.9.4 on 2018-05-22; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> from uasyncio.queues import Queue
>>> q = Queue()
>>> q.put("Item1")
**<generator object 'put' at b6c0ae10>**
>>> q.get()
**<generator object 'get' at b6c0afa0>**
>>>

As you can see the put and get functions are not returning the expected values for what the documentation states. Any idea of what the problem might be? ADDED NOTE: I was expecting to get back the "Item1" with the call to the get() method. I am new to python and I am not sure how to deal with generators. DO I need to do something else to get the "Item1" that I placed in the queue?

  • What values are you expecting? The [documentation](https://github.com/micropython/micropython-lib/blob/master/uasyncio.queues/uasyncio/queues.py) says `put` and `get` both return generator objects. – nekomatic Jan 31 '20 at 15:31
  • I am new to python and not clear how generator object work. I was expecting to get returned "Item1" with the get(). How do I get back the item I placed in the queue? – Oriol de los Santos Feb 03 '20 at 09:19
  • Have a read of [this](https://github.com/peterhinch/micropython-async/blob/master/TUTORIAL.md) and specifically [this bit](https://github.com/peterhinch/micropython-async/blob/master/TUTORIAL.md#35-queue). – nekomatic Feb 03 '20 at 10:09
  • @nekomatic those links are deprecated, please update them with [this](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/TUTORIAL.md) and [this bit](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/TUTORIAL.md#35-queue) – zegulas Feb 20 '21 at 07:39

0 Answers0