#!/usr/bin/env python """Debug URLOPEN and multiprocessing""" from multiprocessing import Process from urllib.request import urlopen # Need this import to trigger the crash. import tkinter # Set whether failure is wanted or noteEdited WANT_TO_FAIL = True # ---------- # main # ---------- if __name__ == '__main__': url = 'https://www.google.com' # Hack fix. Attempt an open before multiprocessing. print('Want to fail? Answer: {}'.format(WANT_TO_FAIL)) if not WANT_TO_FAIL: try: result = urlopen(None) except AttributeError: pass # Multiprocess it. proc = Process(target=urlopen, args=(url,)) proc.start() print('Process aliveness: "{}"'.format(proc.is_alive())) proc.join() print('Process exist status: "{}"'.format(proc.exitcode)) print('Processed failed if result anything other than 0.')