[Python-ideas] Hooks into the IO system to intercept raw file reads/writes
Paul Moore
p.f.moore at gmail.com
Wed Feb 4 10:08:42 CET 2015
On 4 February 2015 at 08:32, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Paul Moore wrote:
>>
>> I found the asyncio docs a bit of a struggle, TBH. Is
>> there a tutorial? The basic idea is something along the lines of
>>
>> https://docs.python.org/3.4/library/asyncio-subprocess.html#subprocess-using-streams
>> but I don't see how I'd modify that code (specifically the "yield from
>> proc.stdout.readline()" bit) to get output from either stdout or
>> stderr, whichever was ready first (and handle the 2 cases
>> differently).
>
>
> One way is to use two subsidiary coroutines, one
> for each pipe.
>
> The following seems to work:
[...]
Thanks! I'll play with that and see if I can get my head round it.
Paul
More information about the Python-ideas
mailing list