qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Implementing "tee" in python asyncio
@ 2023-07-26 20:25 John Snow
  2023-07-27 10:47 ` Daniel P. Berrangé
  0 siblings, 1 reply; 5+ messages in thread
From: John Snow @ 2023-07-26 20:25 UTC (permalink / raw)
  To: Daniel Berrange; +Cc: Paolo Bonzini, qemu-devel

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?

--js



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-27 17:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26 20:25 Implementing "tee" in python asyncio John Snow
2023-07-27 10:47 ` Daniel P. Berrangé
2023-07-27 16:49   ` John Snow
2023-07-27 16:53     ` Daniel P. Berrangé
2023-07-27 16:57       ` John Snow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).