-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[BUG] warnings/output in parallel processes duplicate the output of Process #2371
Comments
Seems related to #1052. |
Rich can only capture the stdout / stderr of its own process. If you want your subprocesses to write to the console, you will need to capture the output and send them to the main process. |
Thanks for your quick reply. I don't think it is possible to capture the output of a multiprocessing step, if the to-be-pickled function has output on the import. Imagine there is a file: print("imported")
def f(x):
return x then from rich.progress import Progress
from concurrent.futures import ProcessPoolExecutor
from func import f
if __name__ == "__main__":
with Progress() as p:
tasks = [p.add_task(f"task {i}", total=1) for i in range(15)]
with ProcessPoolExecutor() as ex: # ⚠️ the import will happen here again! ⚠️
futs = [ex.submit(f, i) for i in range(15)]
for task, fut in zip(tasks, futs):
fut.result()
p.advance(task) @willmcgugan, do you have any suggestions on how to do this? |
It's possible. But it's not straightforward. You can capture the output in your |
In Jupyter the progress bars are rendered in a different process (the browser) and all output is captured. To do that in your terminal you would essentially have to implement something similar. No "workarounds" that I know of I'm afraid. |
I have asked this question on StackOverflow, hopefully, it will help me to solve this issue. |
I hope we solved your problem. If you like using Rich, you might also enjoy Textual |
This is marked as "completed", however, the bug still exists:
|
It's not a bug, as I explained above. Rich can only capture output from its own process. |
You may find a solution to your problem in the docs or issues.
Describe the bug
warnings emitted (or other output) in parallel processes duplicate the output of Process.
See the progress bar doubling:
Run the following to reproduce the bug:
Platform
Click to expand
What platform (Win/Linux/Mac) are you running on? What terminal software are you using?
MacOS
I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.
If you're using Rich in a terminal:
The text was updated successfully, but these errors were encountered: