Why does tkinter work fine with multiprocessing?

The following code hangs without doing anything in python 3.2.2 on linux:

import tkinter
from multiprocessing import Process

def f():
    root = tkinter.Tk()
    label = tkinter.Label(root)
    label.pack()
    root.mainloop()

p = Process(target=f)
p.start()

The only information I found about this problem is issue 5527 , which notes that the problem is related tkinterto the process before branching, that it can be fixed by importing tkinterinside the function, fand that the problem occurs in Linux, but not in Solaris.

Does anyone know what exactly causes this problem, and if it is intentionally or ultimately fixed? Is there any workaround other than importing tkinterlocally everywhere I need (which seems like a bad style)? Do other modules have problems with multiprocessing?

+5
2

, X- ( ). , fork() -ed, . , X- .

Tkinter.py, , , NoDefaultRoot . , X.

Tkinter , .

0

2013 , , .

http://bugs.python.org/issue5527#msg194848
http://bugs.python.org/issue5527#msg195480

, - : Tkinter , ( - ) Tkinter , . Tkinter , Tkinter . fork Tkinter, . (, , .)

0

All Articles