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