threading

Chris Angelico rosuav at gmail.com
Thu Apr 10 11:32:56 EDT 2014


On Fri, Apr 11, 2014 at 1:24 AM, Sturla Molden <sturla.molden at gmail.com> wrote:
> And exactly how is getting all of this correct any easier than just using
> threads and blocking i/o?

For a start, nearly everything Marko just posted should be dealt with
by your library. I don't know Python's asyncio as it's very new and I
haven't yet found an excuse to use it, but with Pike, I just engage
backend mode, set callbacks on the appropriate socket/file/port
objects, and let things happen perfectly. All I need to do is check a
few return values (eg if I ask a non-blocking socket to write a whole
pile of data, it might return that it wrote only some of it, in which
case I have to buffer the rest - not hard but has to be done), and
make sure I always return promptly from my callbacks so as to avoid
lagging out other operations. None of the details of C-level APIs
matter to my high level code.

ChrisA



More information about the Python-list mailing list