2014-02-10 2:38 GMT+01:00 Guido van Rossum <gu...@python.org>: >> I wrote asyncio.wait(*readlines) in my test program and Python became >> slow and ate more and more memory. readlines is declared as >> [proc.stdout.readline(), proc.stderr.readline()]. > > I guess that was Trollius? Tulip's wait() has a lone * after the first > argument so it would have raised an immediate error. (Please always state > whether you observed something in Trollius or Tulip. They may be similar, > but details like this are often different. As you wrote earlier, Python 3 > really is better. :-)
Oh, I missed the fact that Tulip has a different prototype. Yes, I got the issue with Trollius which doesn't have "*" in its prototype. I can maybe add an extra check in Trollius to avoid the trap. >> asyncio.wait(future) calls set(future) which can enter an unlimited >> loop (it's the case for StreamReader.readline coroutine at least...) >> :-( > > Wow, that feels weird. I guess this is also only Trollius? In Tulip > iterating over a Future gives you an exception at the second __next__() > call. In Tulip, I got an AssertionError("yield from wasn't used with future"). Cool :-) > wait() and as_completed() are low-level functions that were defined in PEP > 3148 (concurrent.futures) as taking sets of Futures. And they return > Futures. Ah ok. >> Similar trap: subprocess.Popen(args) expects a list whereas >> EventLoop.subprocess_exec(*args) expects multiple paramters. >> EventLoop.subprocess_exec() should maybe also raise an error if the >> first argument is a iterable (but not bytes or str). > > For those it would be a good idea to add strict type checking. (But note > that there are no Futures involved.) > > For wait() and as_completed(), I suppose you could add an explicit > > assert not isinstance(fs, futures.Future) and not iscoroutine(fs) > > at the top (or raise an explicit TypeError). Ok, I will open an issue with a patch for these checks. Thanks for the explanation. Trollius and Tulip are very close, and sometimes very different :-) Especially when it's related to internals like Task._step(). So why people still use Python 2? :-) Victor