multiprocessing and Tk GUI program (won't work under Linux)

akineko akineko at
Fri Mar 20 04:36:44 CET 2009

Hello everyone,

I have started using multiprocessing module, which is now available
with Python 2.6.
It definitely opens up new possibilities.

Now, I developed a small GUI package, which is to be used from other
It uses multiprocessing and Pipes are used to pump image data/command
to the GUI process.
(I used multiprocessing because I got stack size problem if I used

It works great under Solaris environment, which is my primary
development environment.

When I tried the program under Linux (CentOS5), the program didn't
work (it hung).
My other programs that use multiprocessing work flawlessly under both
Solaris and Linux.

To investigate this problem, I create a much simpler test program. The
test program uses only basic necessary codes, nothing else. But my
simple test program still exhibits the same problem.

My test program display a GUI Button using three possible approaches:

(1) multiprocessing   (Solaris - okay, Linux - hung)
(2) threading            (Solaris - okay, Linux - okay)
(3) none (main thread) (Solaris - okay, Linux - okay)

Is this a bug in a multiprocessing package? Or, I overlooked

Any comments on resolving this problem will be greatly appreciated.

The attached is my test program (sorry for posting a long program).

Thank you!
Aki Niimura

#!/usr/bin/env python

import sys, os
import time
import threading
import multiprocessing

from Tkinter import *

###     class Panel

class Panel:

    def __init__(self, subp='multip'):
        if subp == 'multip':
            print 'multiprocessing module to handle'
            # GUI process
            self.process1 = multiprocessing.Process(target=self.draw)
        elif subp == 'thread':
            print 'threading module to handle'
            # GUI thread
            self.thread1 = threading.Thread(target=self.draw)
#           self.thread1.setDaemon(1)
            print 'main thread to handle'

    def draw(self):
        self.root = Tk()
        w = Button(self.root, text='Exit', command=self.root.quit)

###     Main routine

def main():
    subp = 'multip'
    if len(sys.argv) >= 2:
        if not sys.argv[1] in ['multip', 'thread', 'none',]:
            print 'Invalid option: %s' % sys.argv[1]
            print "Valid options are 'multip', 'thread', 'none'"
            subp = sys.argv[1]
    panel = Panel(subp)
    if subp == 'none':
    while 1:

if __name__ == '__main__':

More information about the Python-list mailing list