print function unable while multiprocessing.Process is being run Not sure if this really is a bug, but the multiprocessing.Process (or Pool) does not allow to print during multiprocessing tasks. I've copied the example from The Python V3.2.2 documentation, library reference, multiprocessing (3rd example). My systems details are: MS windows xp or Windows 7, IDLE, Python 3.2.2 [MSC v.1500 32 bit (Intel)] on win32 from multiprocessing import Process import os def info(title): print(title) print('module name:', __name__) print('parent process:', os.getppid()) print('process id:', os.getpid()) def f(name): info('function f') print('hello', name) if __name__ == '__main__': info('main line') p = Process(target=f, args=('bob',)) p.start() p.join() #return #main line #module name: __main__ #parent process: 1588 #process id: 3700 #but function f doesn't get printed.
Try running without IDLE (double click, right-click run, Command Prompt window, or paste into interpreter window). IDLE runs code in a subprocess with stdout directed back to the IDLE process, so it occasionally affects otherwise legal and correct Python code.
Thanks Terry, That does solve the problem, so the bug is really with IDLE (I got a previous Issue (12967) reported which also was connected to the stdout). I changed the component to IDLE as the lib. is working as it should do.
This may be a 'cannot fix' issue due to the way Windows connects the output and input streams of various processes. It would be helpful to know if *nix has the same difference of behavior between interpreter and IDLE shell. Otherwise some experiments are needed.