From: "Daniel P. Berrangé" <berrange@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: Implementing "tee" in python asyncio
Date: Thu, 27 Jul 2023 11:47:20 +0100 [thread overview]
Message-ID: <ZMJLOJYueAWYA1mN@redhat.com> (raw)
In-Reply-To: <CAFn=p-aKWG7r2zRdQ-O6kod_jVOTMELGi_ObbKBAM=9ZgXt7Ww@mail.gmail.com>
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 :|
next prev parent reply other threads:[~2023-07-27 11:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 20:25 Implementing "tee" in python asyncio John Snow
2023-07-27 10:47 ` Daniel P. Berrangé [this message]
2023-07-27 16:49 ` John Snow
2023-07-27 16:53 ` Daniel P. Berrangé
2023-07-27 16:57 ` John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZMJLOJYueAWYA1mN@redhat.com \
--to=berrange@redhat.com \
--cc=jsnow@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.