Oh, now you have me confused. What you just pushed ( https://code.google.com/p/tulip/source/detail?r=b288da71fb40) seems to be using a global variable in the tasks module. Isn't it a bit premature to push this without any further discussion? Luca never commented on your suggestion last February.
On Thu, Jul 3, 2014 at 8:58 AM, Victor Stinner <[email protected]> wrote: > Oops, I forgot the change the subject of my email. I first used > tasks.task_factory, but in fact it works use > BaseEventLoop.task_factory which is less global. > > Victor > > 2014-07-03 17:57 GMT+02:00 Victor Stinner <[email protected]>: > > Hi, > > > > In february, Luca Sbardella asked to add a "task_factory" in asyncio > > to be to use a custom Task class instead of creating directly Task > > instances: > > https://groups.google.com/d/msg/python-tulip/j-lAnkk4d5k/VTRRO1IGX4gJ > > > > He's using a custom Task class which also supports yield, not only > yield-from. > > > > I modified Trollius in version 0.4 to support asyncio coroutines. I > > had to modify Task._step() and some other parts of the code for that. > > > > I just ported the greenio project (asyncio event loop scheduling work > > in greenlet) to Trollius and I hitted the same issue. > > asyncio.Task._step() creates Task instance using async(), but > > greenio.GreenTask must be used instead of asyncio.Task to interoperate > > with greenlet. > > > > Pull request: > > https://github.com/1st1/greenio/pull/5 > > > > I propose the following change in asyncio, add a new > > BaseEventLoop.task_factory attribute: > > https://codereview.appspot.com/110820049/#ps20001 > > > > The class variable can be modified before event loops are created, to > > modify the factory on all threads. Or it can be modified on a single > > event loop, even after the event loop creation. > > > > The limitation is that all libraries must agree on the task factory. > > For example, greenio wants to use greenio.GreenTask whereas Pulsar > > wants to use > > > > Victor > -- --Guido van Rossum (python.org/~guido)
