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.

Author Delgan
Recipients Delgan
Date 2019-10-18.20:48:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571431695.05.0.294533702536.issue38520@roundup.psfhosted.org>
In-reply-to
Content
Hi.

I noticed that there exists the function "threading.main_thread()", but there is no equivalent for the "multiprocessing" module.

Is there a reason for this absence?

These StackOverflow questions are related to this problem:
- https://stackoverflow.com/questions/42283265/how-to-determine-if-running-current-process-is-parent
- https://stackoverflow.com/questions/30790660/python-multiprocessing-name-of-the-main-process
- https://stackoverflow.com/questions/18216050/is-there-a-way-to-check-if-a-module-is-being-loaded-by-multiprocessing-standard

Current proposed solutions have flaws.
It's suggested to check if "current_process().name == 'MainProcess'" but anyone can re-write the name of a process with "current_process().name = 'foobar'" so this does not seem to be a reliable solution.
Another alternative is to check for the type of the process, which is different for main and child, respectively "mulitprocessing.process._MainProcess" and "multiprocessing.process.Process". This is obviously hacky as it relies on implementation detail.

What are you thoughts on adding a new "multiprocessing.main_process()" function?
History
Date User Action Args
2019-10-18 20:48:15Delgansetrecipients: + Delgan
2019-10-18 20:48:15Delgansetmessageid: <1571431695.05.0.294533702536.issue38520@roundup.psfhosted.org>
2019-10-18 20:48:14Delganlinkissue38520 messages
2019-10-18 20:48:14Delgancreate