#NEWLINE# def test_4_async_call( self ) : #NEWLINE# #INDENT# 'send a bunch of requests and then wait for responses\n        ' #NEWLINE# num_calls = 9999 #NEWLINE# old_blocking = self . _client_sock . setblocking ( 0 ) #NEWLINE# try : #NEWLINE# #INDENT# e = rpc . EndPoint ( self . _client_sock ) #NEWLINE# s = set ( ) #NEWLINE# for i in range ( 1 , ( num_calls + 1 ) ) : #NEWLINE# #INDENT# s . add ( e . send_request ( b'resp' , [ i ] ) ) #NEWLINE# #UNINDENT# sum = 0 #NEWLINE# while s : #NEWLINE# #INDENT# e . block ( ) #NEWLINE# e . process ( ) #NEWLINE# done = set ( ) #NEWLINE# for x in s : #NEWLINE# #INDENT# r = e . get_response ( x ) #NEWLINE# if ( r is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( res , error ) = r #NEWLINE# assert ( error is None ) #NEWLINE# sum += res #NEWLINE# done . add ( x ) #NEWLINE# #UNINDENT# assert done . issubset ( s ) #NEWLINE# s -= done #NEWLINE# #UNINDENT# assert ( sum == ( ( ( 1 + num_calls ) * num_calls ) / 2 ) ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# self . _client_sock . setblocking ( old_blocking )