Issue 13220: print function unable while multiprocessing.Process is being run
Issue13220
Created on 2011-10-19 15:28 by Ben.thelen, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| mp.py | 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(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.
|
|||
| msg146141 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
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) * ![]() |
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) * ![]() |
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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:22 | admin | set | github: 57429 |
| 2017-07-08 01:58:23 | terry.reedy | set | status: open -> closed superseder: idle3 shell os.system swallows shell command output resolution: duplicate stage: test needed -> resolved |
| 2017-07-08 01:20:31 | ppperry | set | nosy:
+ ppperry messages: + msg297920 |
| 2017-06-30 00:52:15 | terry.reedy | set | assignee: terry.reedy versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.4, Python 3.5 |
| 2014-10-03 03:52:30 | terry.reedy | set | versions: + Python 3.5, - Python 3.2, Python 3.3 |
| 2012-10-16 21:07:18 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages:
+ msg173095 |
| 2011-10-25 22:55:09 | terry.reedy | set | messages: + msg146402 |
| 2011-10-25 14:16:19 | Ben.thelen | set | messages:
+ msg146368 components: + IDLE, - Library (Lib) |
| 2011-10-21 22:00:34 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg146141 |
| 2011-10-19 21:58:16 | ezio.melotti | set | nosy:
+ jnoller stage: test needed |
| 2011-10-19 15:28:01 | Ben.thelen | create | |
