This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: print function unable while multiprocessing.Process is being run
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.7, Python 3.6
Status: closed Resolution: duplicate
Dependencies: Superseder: idle3 shell os.system swallows shell command output
View: 11820
Assigned To: terry.reedy Nosy List: Ben.thelen, jnoller, ppperry, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2011-10-19 15:28 by Ben.thelen, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit Ben.thelen, 2011-10-19 15:28
Messages (6)
msg145913 - (view) Author: ben (Ben.thelen) Date: 2011-10-19 15:28
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('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',))


#main line
#module name: __main__
#parent process: 1588
#process id: 3700

#but function f doesn't get printed.
msg146141 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-10-21 22:00
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.
msg146368 - (view) Author: ben (Ben.thelen) Date: 2011-10-25 14:16
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.
msg146402 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-10-25 22:55
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.
msg173095 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-10-16 21:07
*nix has the same difference of behavior between interpreter and IDLE shell.

With issue9290 patch the "function f" line also printed. And then the script hangs.
msg297920 - (view) Author: (ppperry) Date: 2017-07-08 01:20
Duplicate of issue11820.
Date User Action Args
2022-04-11 14:57:22adminsetgithub: 57429
2017-07-08 01:58:23terry.reedysetstatus: open -> closed
superseder: idle3 shell os.system swallows shell command output
resolution: duplicate
stage: test needed -> resolved
2017-07-08 01:20:31ppperrysetnosy: + ppperry
messages: + msg297920
2017-06-30 00:52:15terry.reedysetassignee: terry.reedy
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.4, Python 3.5
2014-10-03 03:52:30terry.reedysetversions: + Python 3.5, - Python 3.2, Python 3.3
2012-10-16 21:07:18serhiy.storchakasetnosy: + serhiy.storchaka

messages: + msg173095
versions: + Python 2.7, Python 3.3, Python 3.4
2011-10-25 22:55:09terry.reedysetmessages: + msg146402
2011-10-25 14:16:19Ben.thelensetmessages: + msg146368
components: + IDLE, - Library (Lib)
2011-10-21 22:00:34terry.reedysetnosy: + terry.reedy
messages: + msg146141
2011-10-19 21:58:16ezio.melottisetnosy: + jnoller

stage: test needed
2011-10-19 15:28:01Ben.thelencreate