#NEWLINE# def test_fork_with_active_worker( self ) : #NEWLINE# #INDENT# event1 = self . client . build_msg ( 'raven.events.Message' , message = 'parent' ) #NEWLINE# event2 = self . client . build_msg ( 'raven.events.Message' , message = 'child' ) #NEWLINE# url = urlparse ( self . url ) #NEWLINE# ( fd , filename ) = mkstemp ( ) #NEWLINE# try : #NEWLINE# #INDENT# os . close ( fd ) #NEWLINE# transport = LoggingThreadedScheme ( filename , url ) #NEWLINE# transport . async_send ( event1 , None , None , None ) #NEWLINE# childpid = os . fork ( ) #NEWLINE# if ( childpid == 0 ) : #NEWLINE# #INDENT# transport . async_send ( event2 , None , None , None ) #NEWLINE# transport . get_worker ( ) . stop ( ) #NEWLINE# os . _exit ( 0 ) #NEWLINE# #UNINDENT# os . waitpid ( childpid , 0 ) #NEWLINE# assert os . path . isfile ( filename ) #NEWLINE# transport . get_worker ( ) . stop ( ) #NEWLINE# with open ( filename , 'r' ) as logfile : #NEWLINE# #INDENT# events = dict ( ( x . strip ( ) . split ( ) for x in logfile . readlines ( ) ) ) #NEWLINE# #UNINDENT# assert ( events == { #NEWLINE# #INDENT# str ( os . getpid ( ) ) : 'parent' , #NEWLINE# str ( childpid ) : 'child' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# os . remove ( filename )