#NEWLINE# def function_wrapper( queue , function , * args , **kwargs ) : #NEWLINE# #INDENT# PR_SET_PDEATHSIG = 1 #NEWLINE# libc . prctl ( PR_SET_PDEATHSIG , signal . SIGHUP ) #NEWLINE# def signal_handler_sighup( * args ) : #NEWLINE# #INDENT# logger . warning ( 'Crawler parent process died, so exiting... Bye!' ) #NEWLINE# queue . close ( ) #NEWLINE# exit ( 1 ) #NEWLINE# #UNINDENT# signal . signal ( signal . SIGHUP , signal_handler_sighup ) #NEWLINE# result = None #NEWLINE# try : #NEWLINE# #INDENT# args = args [ 0 ] #NEWLINE# result = function ( * args ) #NEWLINE# if isinstance ( result , types . GeneratorType ) : #NEWLINE# #INDENT# result = list ( result ) #NEWLINE# #UNINDENT# queue . put ( ( result , None ) ) #NEWLINE# queue . close ( ) #NEWLINE# sys . exit ( 0 ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# queue . put ( ( None , e ) ) #NEWLINE# queue . close ( ) #NEWLINE# sys . exit ( 1 )