Protocol callbacks don't have a return value and can't (or shouldn't) block. You can use async() or Task() to spawn a coroutine. You might also look at open_connection(), which has a lot of the logic you describe. On Dec 23, 2013 7:52 AM, "Tobias Oberstein" <[email protected]> wrote:
> Hi, > > I am wondering how to call coroutines within > asyncio.Protocol.data_received: > > > http://stackoverflow.com/questions/20746619/calling-coroutines-in-asyncio-protocol-data-received/20748559 > > I am coming from Twisted, where doing asynchronous stuff within the > corresponding callback ("dataReceived") is ok. > > Now, Twisted does internal buffering of data incoming from a socket. > > Am I supposed to do that myself and decouple the (asynchronous) processing > via a receive queue and a Future to signal availability of received data? > > Like so: > > https://github.com/oberstet/scratchbox/blob/master/python/asyncio/client.py > https://github.com/oberstet/scratchbox/blob/master/python/asyncio/server.py > > ? > > Thanks > /Tobias >
