#NEWLINE# def test_shutdown_server_while_client_running( ) : #NEWLINE# #INDENT# "\n    start server with 1000 elements in queue\n    \n    start client\n    \n    stop server -> client should catch exception, but can't do anything, \n        writing to fail won't work, because server went down\n    \n    check if the final_result and the args dump end up to include\n    all arguments given \n    " #NEWLINE# global PORT #NEWLINE# PORT += 1 #NEWLINE# n = 1000 #NEWLINE# p_server = mp . Process ( target = start_server , args = ( n , ) ) #NEWLINE# p_server . start ( ) #NEWLINE# time . sleep ( 1 ) #NEWLINE# PORT += 1 #NEWLINE# p_client = mp . Process ( target = start_client , args = ( 2 , ) ) #NEWLINE# p_client . start ( ) #NEWLINE# time . sleep ( 2 ) #NEWLINE# os . kill ( p_server . pid , signal . SIGTERM ) #NEWLINE# p_server . join ( 200 ) #NEWLINE# p_client . join ( 200 ) #NEWLINE# try : #NEWLINE# #INDENT# assert ( not p_server . is_alive ( ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# p_server . terminate ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# assert ( not p_client . is_alive ( ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# p_client . terminate ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# fname = 'jobmanager.dump' #NEWLINE# with open ( fname , 'rb' ) as f : #NEWLINE# #INDENT# data = jobmanager . JobManager_Server . static_load ( f ) #NEWLINE# #UNINDENT# args_set = set ( data [ 'args_dict' ] . keys ( ) ) #NEWLINE# final_result = data [ 'final_result' ] #NEWLINE# final_res_args = { a [ 0 ] for a in final_result } #NEWLINE# args_ref = range ( 1 , n ) #NEWLINE# set_ref = set ( ) #NEWLINE# for a in args_ref : #NEWLINE# #INDENT# set_ref . add ( binfootprint . dump ( a ) ) #NEWLINE# #UNINDENT# set_recover = ( set ( args_set ) | set ( final_res_args ) ) #NEWLINE# intersec_set = ( set_ref - set_recover ) #NEWLINE# if ( len ( intersec_set ) == 0 ) : #NEWLINE# #INDENT# print ( '[+] no arguments lost!' ) #NEWLINE# #UNINDENT# assert ( len ( intersec_set ) == 0 ) , 'NOT all arguments found in dump!'