2014-12-18 19:30 GMT+01:00 Paul Sokolovsky <[email protected]>:
> "Remove and return an item from the queue. If you yield from get(),
> wait until a item is available. If you don't yield from get() (which
> apparently means calling it directly), it won't wait until item is
> available (but do something else, which is underspecified)".
Queue.get() and Queue.put() are not special. They must be used as any
other coroutine: you must use them with yield-from.
Maybe the link on "This method is a coroutine." must explain better
how a coroutine must be used?
Example of code:
---
import asyncio
q = asyncio.Queue()
q.get()
---
Output when running the code in debug mode:
---
$ PYTHONASYNCIODEBUG=1 python3.4 test.py
<CoroWrapper Queue.get() running at
/home/haypo/prog/python/default/Lib/asyncio/queues.py:160, created at
x.py:4> was never yielded from
Coroutine object created at (most recent call last):
File "tes.py", line 3, in <module>
q.get()
---
You get the same error with a random coroutine:
---
import asyncio
@asyncio.coroutine
def transaction():
yield from asyncio.sleep(1)
print("transation done")
transaction()
---
Victor