1

I've have an application which uses tkMessageBox module, multiprocessing module and urllib2 module. For some unknown reason, python child process is crashing silently while fetching a url. This only happens when tkMessageBox module is imported.

Here is my sample code to reproduce the problem:

import tkMessageBox
import multiprocessing
import time
import urllib2


def run():
    print "Starts"
    urllib2.urlopen("http://stackoverflow.com").read()
    print "Ends"


def start_process():
    p = multiprocessing.Process(target=run)
    p.start()


def main():
    start_process()
    while True:
        time.sleep(1)

if __name__ == "__main__":
    main()

Output:

python test_tk.py 
Starts    

If I comment the tkMessageBox import line that program works successfully.

Output:

python test_tk.py 
Starts
Ends

Python & OS Version:

python
ActivePython 2.7.8.10 (ActiveState Software Inc.) based on
Python 2.7.8 (default, Jul  7 2014, 20:30:57) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
>>> Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
platform.mac_ver()
('10.10.2', ('', '', ''), 'x86_64')

I don't know what's going on here. I've tested it on MacOSX 10.10.2 and it's reproducible. But on Ubuntu 14.04 and Windows 7 above code seems to be working fine. I would appreciate if somebody could help me with this issue.

Thanks,
Vinod

Vinod Sharma
  • 883
  • 6
  • 13

1 Answers1

0

There's several problems with Tk and OS X. https://www.python.org/download/mac/tcltk/

You should look into updating your Tcl (or using a different implementation) or Python.

Eugene K
  • 3,381
  • 2
  • 23
  • 36
  • Thanks Eugene. I have updated my tcl version to 8.5.17 from active state. no luck. Though latest is 8.6.x version but it can't be used with python on MacOS for the reason explained here: http://stackoverflow.com/questions/21129498/idle-warns-against-an-old-tcl-version-even-though-ive-installed-a-newer-version – Vinod Sharma Feb 24 '15 at 00:49
  • Do you have to use to use Tk? It seems Tk isn't very functional with OSX. The mailinglist at http://wiki.tcl.tk/1013 might be able to help you. – Eugene K Feb 24 '15 at 17:20