[issue24573] Using multiprocessing with tkinter frames in Python 3.4.3 crashes in OS X

Ned Deily report at bugs.python.org
Mon Jul 6 21:32:44 CEST 2015


Ned Deily added the comment:

A web search will find multiple hits for problems with using Tk (and Tkinter) with multiprocess on OS X and elsewhere.  On OS X, there is a well-known and documented restriction that impacts Tk-based apps:

"When launching separate processes using the fork function, you must always follow a call to fork with a call to exec or a similar function. Applications that depend on the Core Foundation, Cocoa, or Core Data frameworks (either explicitly or implicitly) must make a subsequent call to an exec function or those frameworks may behave improperly."

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/AboutThreads/AboutThreads.html

For a specific example of problems using tkinter and multiprocessing see:
http://stackoverflow.com/questions/23599087/multiprocessing-python-core-foundation-error

Some suggest that you *might* be able to get things to work as long as you defer importing tkinter (and, thus, initializing Tcl and Tk) until after all of the processes are created.  But, in general, it's not a good idea to separate tkinter calls across multiple processes.  See Bryan Oakley's advice in the above SO link:

"You'll need to keep all GUI code in the master process, and have your other process communicate with it via a queue."

----------
resolution:  -> third party
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24573>
_______________________________________


More information about the Python-bugs-list mailing list