[BUG] warnings/output in parallel processes duplicate the output of Process
See original GitHub issueYou 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:
from rich.progress import Progress
from concurrent.futures import ProcessPoolExecutor
def warns(x):
import warnings
warnings.warn("yo")
return x
# This also reproduces the error:
# def warns(x):
# print("yo")
# return x
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:
futs = [ex.submit(warns, i) for i in range(15)]
for task, fut in zip(tasks, futs):
fut.result()
p.advance(task)
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:
python -m rich.diagnose
pip freeze | grep rich
โญโโโโโโโโโโโโโโโโโโโโโโโโโ <class 'rich.console.Console'> โโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ A high level console interface. โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ <console width=94 ColorSystem.TRUECOLOR> โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ
โ color_system = 'truecolor' โ
โ encoding = 'utf-8' โ
โ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> โ
โ height = 51 โ
โ is_alt_screen = False โ
โ is_dumb_terminal = False โ
โ is_interactive = True โ
โ is_jupyter = False โ
โ is_terminal = True โ
โ legacy_windows = False โ
โ no_color = False โ
โ options = ConsoleOptions( โ
โ size=ConsoleDimensions(width=94, height=51), โ
โ legacy_windows=False, โ
โ min_width=1, โ
โ max_width=94, โ
โ is_terminal=True, โ
โ encoding='utf-8', โ
โ max_height=51, โ
โ justify=None, โ
โ overflow=None, โ
โ no_wrap=False, โ
โ highlight=None, โ
โ markup=None, โ
โ height=None โ
โ ) โ
โ quiet = False โ
โ record = False โ
โ safe_box = True โ
โ size = ConsoleDimensions(width=94, height=51) โ
โ soft_wrap = False โ
โ stderr = False โ
โ style = None โ
โ tab_size = 8 โ
โ width = 94 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโโโ <class 'rich._windows.WindowsConsoleFeatures'> โโโโโฎ
โ Windows features available. โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ WindowsConsoleFeatures(vt=False, truecolor=False) โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ
โ truecolor = False โ
โ vt = False โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโโโโโโ Environment Variables โโโโโโโโฎ
โ { โ
โ 'TERM': 'xterm-256color', โ
โ 'COLORTERM': 'truecolor', โ
โ 'CLICOLOR': None, โ
โ 'NO_COLOR': None, โ
โ 'TERM_PROGRAM': 'iTerm.app', โ
โ 'COLUMNS': None, โ
โ 'LINES': None, โ
โ 'JPY_PARENT_PID': None, โ
โ 'VSCODE_VERBOSE_LOGGING': None โ
โ } โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
platform="Darwin"
rich==12.2.0
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Troubleshooting the ParallelRunStep - Azure Machine Learning
The -1 part indicates ignoring all failures during processing. ... ParallelRunStep will use the output only for the error thresholdย ...
Read more >log messages appearing twice with Python Logging
It seems that if you output something to the logger ... I was struggling with the same issue in the context of multiple...
Read more >Embarrassingly parallel for loops - Joblib - Read the Docs
โlokyโ used by default, can induce some communication and memory overhead when exchanging input and output data with the worker Python processes. On...
Read more >multiprocessing โ Process-based parallelism โ Python 3.11 ...
In multiprocessing , processes are spawned by creating a Process object and ... a lock to ensure that only one process prints to...
Read more >Duplicate output file | Apple Developer Forums
Hi everyone. Multiple commands produce '/Users/username/Library/Developer/Xcode/DerivedData/myApp-cqsvatsweajrlwgztrbdqodhawmh/Build/Products/Debug-ย ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Itโs possible. But itโs not straightforward. You can capture the output in your
func.py
and send that via a pipe or other IPC mechanism to your main process for printing. But that is a project in itselfโฆI have asked this question on StackOverflow, hopefully, it will help me to solve this issue.