#NEWLINE# def client_proc( computation , njobs , coro = None ) : #NEWLINE# #INDENT# if ( yield computation . schedule ( ) ) : #NEWLINE# #INDENT# raise Exception ( 'schedule failed' ) #NEWLINE# #UNINDENT# def recv_results( coro = None ) : #NEWLINE# #INDENT# for i in range ( njobs ) : #NEWLINE# #INDENT# msg = ( yield coro . receive ( ) ) #NEWLINE# print ( ( '    result for job %d: %s' % ( i , msg ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# results_coro = asyncoro . Coro ( recv_results ) #NEWLINE# for i in range ( njobs ) : #NEWLINE# #INDENT# cobj = C ( i ) #NEWLINE# cobj . n = random . uniform ( 5 , 10 ) #NEWLINE# print ( ( '  request %d: %s' % ( i , cobj . n ) ) ) #NEWLINE# rcoro = ( yield rcoro_scheduler . schedule ( compute , cobj , results_coro ) ) #NEWLINE# if ( not isinstance ( rcoro , asyncoro . Coro ) ) : #NEWLINE# #INDENT# print ( ( 'failed to create rcoro %s: %s' % ( i , rcoro ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# ( yield results_coro . finish ( ) ) #NEWLINE# ( yield computation . close ( ) )