peterhinch / micropython-async

Application of uasyncio to hardware interfaces. Tutorial and code.
MIT License
742 stars 168 forks source link

Primitives Queue query #89

Closed krishnak closed 2 years ago

krishnak commented 2 years ago

https://github.com/peterhinch/micropython-async/blob/master/v3/primitives/queue.py

When I use this code, it works as intended if I am trying to get an item by waiting on the get method.

However if I add an object to queue on REPL and then try to get it back, it prints out as below - how can I use it like a Vector/List

myq = Queue(50)

myq.put("Thomas") <generator object 'put' at 3ffee730> x = myq.get() print(x) <generator object 'get' at 3ffee8a0>

peterhinch commented 2 years ago

You can't use uasyncio at the REPL like that. You have to await these methods in an asynchronous task as per the demo. I suggest you study the tutorial a bit more to get to grips with uasyncio fundamentals.