qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing "tee" in python asyncio


From: Daniel P . Berrangé
Subject: Re: Implementing "tee" in python asyncio
Date: Thu, 27 Jul 2023 11:47:20 +0100
User-agent: Mutt/2.2.9 (2022-11-12)

On Wed, Jul 26, 2023 at 04:25:34PM -0400, John Snow wrote:
> Hi folks,
> 
> I'm currently wondering how to take a StreamReader as found on
> https://docs.python.org/3/library/asyncio-subprocess.html#asyncio.subprocess.Process
> and to consume the data while optionally re-streaming it to a
> secondary consumer.
> 
> What I'd like to do is create a StreamWatcher class that consumes
> console data while optionally logging to python logging and/or a file;
> but re-buffers the data into an async stream where an additional
> consumer is free to use the "standard asyncio API" to consume console
> data at their leisure in a way that's unsurprising.
> 
> What I'd like this *for* is to be able to do aggressive logging of
> stdout/stderr and console data without denying tests the ability to
> consume the data as they see fit for their testing purposes. I want to
> have my cake and eat it too, and we don't do a good job of managing
> this consistently across the board.
> 
> I am wondering if there's any way around creating a literal socketpair
> and suffering the creation of a full four StreamReader/StreamWriter
> instances (one pair per socket...) and then just hanging on to the
> "unused" reader/writer per each. It seems kind of foolishly excessive.
> It also seems like it might be a pain in the butt if I want
> cross-platform compatibility with windows for the machine appliance.
> 
> Anyone got any bright ideas?

Don't bother with any of the above, just add 'logfile=/path/to/log'
to the -chardev argument.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




reply via email to

[Prev in Thread] Current Thread [Next in Thread]