Send data to asyncio coroutine

Javier jcarmena at gmail.com
Sat Aug 1 12:07:48 EDT 2015


El martes, 21 de julio de 2015, 13:31:56 (UTC+2), Javier  escribió:
> Hello, I'm trying to understand and link asyncio with ordinary coroutines. Now I just want to understand how to do this on asyncio:
> 
> 
> def foo():
>     data = yield 8
>     print(data)
>     yield "bye"
>     
> def bar():
>     f = foo()
>     n = f.next()
>     print(n)
>     message = f.send("hello")
>     print(message)
> 
> 
> What is the equivalent for coro.send("some data") in asyncio?
> 
> coro.send on an asyncio coroutine throws AssertionError: yield from wasn't used with future.
> 
> 
> Thank you




Asyncio is a crazy headache! I realized that I can't use asyncio tcp servers with pickle! Asyncio is good as a concept but bad in real life. 

I think python's non blocking I/O is far from being something useful for developers till non-async code can invoke async code transparently. Duplicating all code/libs when you realize that something not fits asyncio is not a solution and even less a pythonic solution.




More information about the Python-list mailing list