Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture printout while c++ program is running #76

Open
FlorianBury opened this issue Oct 4, 2023 · 3 comments
Open

Capture printout while c++ program is running #76

FlorianBury opened this issue Oct 4, 2023 · 3 comments

Comments

@FlorianBury
Copy link

Hi,

Thanks a lot for this very handy package, it turned out quite useful! There is one thing I would like to implement in my code however, but I do not know how or whether it is possible (my IO experience is limited).

I have a C++ library that does some lengthy computations. I use wurlitzer to capture the printout and pass it through my python logging object (to prettify it, but also capture the printout when the log is saved to file). The issue is however that the printout is then saved at the end of the computation, but the program outputs lines every so often, and can take up to several minutes or dozens. With wurlitzer this means that for the entire duration of the computation, I am waiting blindly.

Is there a way (with or without wurlitzer), to obtain every new line and pass it through the logger (or any other output), while the computation is still ongoing ? Maybe a loop that checks regularly if something was added to the stdout and does something with it ?

Thanks in advance !

@gilirosenberg12
Copy link

Agreed, I would love to see this feature as well!

@kefeimo
Copy link

kefeimo commented Apr 21, 2024

I have a programming with similar issue as well. Would love to see this feature implemented.

@minrk
Copy link
Owner

minrk commented Apr 23, 2024

wurlitzer does capture continuously in a background thread.

This notebook illustrates continuously capturing output to a Python logger.

If this is asking for capturing output while a program is holding the GIL for a long time, that can't be implemented in Python. We would have to reimplement this with a GIL-less version where all the code to read the pipes runs without the GIL, e.g. in Rust or Cython or some such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants