使用OS X中的Python 3.4.3的基本tkinter接口进行多处理崩溃

时间:2015-07-05 23:38:08

标签: python python-3.x tkinter multiprocessing

我试图将tkinter帧作为单独的进程运行,但是当我使用相对基本的脚本执行此操作时,该过程要么完成而不启动任何窗口或崩溃。

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...

如果我取消注释" runDemo(name)"这至少会运行。排队并注释掉过程调用;但是,这会使窗口实例在同一进程中按顺序生成,而不是根据需要在单独的进程中生成。

据我所知,此代码中的所有内容都应按预期运行单独的进程。

这是在OS X 10.10.4上使用Python 3.4.3。我主要在PyCharm Community Edition 4.5中开发,但是当在PyCharm中运行或直接从命令行运行时会发生这种情况。有线索吗?

已更新以添加崩溃日志:

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

0 个答案:

没有答案