I am new to IPython and would like to print intermediate results for stdout when running IPython parallel cluster functions. (I know that with several processes this can lead to output failure, but it is fine - it is just for testing / debugging, and the processes that I started are long enough so that such a collision is unlikely.) I checked the documentation for IPython, but not can find an example when the parallelism function is printed. Basically, I'm looking for a way to redirect subprocess output to the main stdout, the equivalent of IPython
subprocess.Popen( ... , stdout=...)
Printing inside the process does not work:
rc = Client() dview = rc() def ff(x): print(x) return x**2 sync = dview.map_sync(ff,[1,2,3,4]) print('sync res=%s'%repr(sync)) async = dview.map_async(ff,[1,2,3,4]) print('async res=%s'%repr(async)) print(async.display_outputs())
returns
sync res=[1, 4, 9, 16] async res=[1, 4, 9, 16]
So, the calculation is done correctly, but the print statement in the ff function is never printed, even when all processes are returned. What am I doing wrong? How to get a "print" for work?
python parallel-processing printing ipython ipython-parallel
user1470788
source share