Am 23.12.2013 23:29, schrieb Antoine Pitrou:
On Mon, 23 Dec 2013 23:25:58 +0100
Tobias Oberstein
<[email protected]> wrote:
In short: I can't call a coroutine from data_received, but I can call an
inlineCallbacks-decorated functions in dataReceived. This is a major
difference.

I'm willing to bet that you're doing something wrong here. Can you post
code snippets?

http://stackoverflow.com/questions/20746619/calling-coroutines-in-asyncio-protocol-data-received

I think you should instead write your coroutine as a separate function
or method and then schedule it from data_received() using e.g.
asyncio.async().

I can't see how that would help with "yield from" proliferation. I guess I can sum up my issue like this:

If I want users to be able to write their app level protocol handlers as coroutines, that means I have to use "yield from" everywhere inside my framework. And that does not work on Python 2. So I cannot have one (mostly) shared codebase. Twisted is far less intrusive. Or maybe I am just too dumb.


Perhaps it would be more convenient to be able to write data_received()
as a coroutine; that's a possible enhancement.

That would be nice, but is a minor problem. I do already have a working solution for this.

Thanks for your comments!
/Tobias


Regards

Antoine.



Reply via email to