#NEWLINE# def _test_restart_service_on_sighup( self , service , workers = 1 ) : #NEWLINE# #INDENT# 'Test that a service correctly (re)starts on receiving SIGHUP.\n\n        1. Start a service with a given number of workers.\n        2. Send SIGHUP to the service.\n        3. Wait for workers (if any) to (re)start.\n        ' #NEWLINE# self . _start_server ( callback = service , workers = workers ) #NEWLINE# os . kill ( self . service_pid , signal . SIGHUP ) #NEWLINE# expected_msg = ( ( FAKE_START_MSG * workers ) * 2 ) #NEWLINE# expected_size = len ( expected_msg ) #NEWLINE# condition = ( lambda : ( os . path . isfile ( self . temp_file ) and ( os . stat ( self . temp_file ) . st_size == expected_size ) ) ) #NEWLINE# utils . wait_until_true ( condition , timeout = 5 , sleep = 0.1 , exception = RuntimeError ( ( 'Timed out waiting for file %(filename)s to be created and its size become equal to %(size)s.' % { #NEWLINE# #INDENT# 'filename' : self . temp_file , #NEWLINE# 'size' : expected_size , #NEWLINE# #UNINDENT# } ) ) ) #NEWLINE# with open ( self . temp_file , 'r' ) as f : #NEWLINE# #INDENT# res = f . readline ( ) #NEWLINE# self . assertEqual ( expected_msg , res )