Multiprocessing crash with basic tkinter interface with Python 3.4.3 on OS X

I'm trying to start tkinter frames as separate processes, but when I do it using a relatively main script, the process either ends without launching any windows, or it crashes.

from tkinter import *
from multiprocessing import Process

titles = ['first', 'second', 'third', 'fourth']

class Demo(Frame):
    def __init__(self, parent=None, fname="", **options):
        Frame.__init__(self, master=parent, **options)
        self.pack()
        Label(self, text=fname).pack(side=TOP)
        Button(self, text="Quit!", command=self.quit).pack(side=TOP, fill=BOTH)

def runDemo(name):
    Demo(fname=name).mainloop() #call and run class instance...

if __name__=="__main__":
    for name in titles:
        #runDemo(name)
        Process(target=runDemo, args=(name,)).start() #spawn process...

      

This is at least done if I uncomment the "runDemo (name)" line and comment out the call to Process; however, in this case, the window instances appear in sequence in the same process, rather than in separate processes at will.

As far as I can tell, everything in this code should start separate processes as expected.

This uses Python 3.4.3 for OS X 10.10.4. I am primarily developing in PyCharm Community Edition 4.5, but this happens when run either in PyCharm or directly from the command line. Any hints?

Updated to add crash logs:

Process:               Python [24917]
Path:                  /Library/Frameworks/Python.framework/Versions/3.4/Resources/Python.app/Contents/MacOS/Python
Identifier:            Python
Version:               3.4.3 (3.4.3)
Code Type:             X86-64 (Native)
Parent Process:        Python [24916]
Responsible:           pycharm [20749]
User ID:               502

Date/Time:             2015-07-05 17:55:24.271 -0700
OS Version:            Mac OS X 10.10.4 (14E46)
Report Version:        11
Anonymous UUID:        02AA8592-98B0-87D9-7BA0-938C3E157C6B

Sleep/Wake UUID:       DABF4CDD-2502-4E5C-84EB-74CD9BBD6C33

Time Awake Since Boot: 180000 seconds
Time Since Wake:       8700 seconds

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000110

VM Regions Near 0x110:
--> 
__TEXT                 0000000100000000-0000000100001000 [    4K] r-x/rwx SM=COW  /Library/Frameworks/Python.framework/Versions/3.4/Resources/Python.app/Contents/MacOS/Python

Application Specific Information:
*** multi-threaded process forked ***
crashed on child side of fork pre-exec

      

+3


source to share





All Articles