#NEWLINE# def _run_scenario( self , cls , method , context , args ) : #NEWLINE# #INDENT# 'Runs the specified benchmark scenario with given arguments.\n\n        :param cls: The Scenario class where the scenario is implemented\n        :param method: Name of the method that implements the scenario\n        :param context: Benchmark context that contains users, admin & other\n                        information, that was created before benchmark started.\n        :param args: Arguments to call the scenario method with\n\n        :returns: List of results fore each single scenario iteration,\n                  where each result is a dictionary\n        ' #NEWLINE# timeout = self . config . get ( 'timeout' , 600 ) #NEWLINE# concurrency = self . config . get ( 'concurrency' , 1 ) #NEWLINE# duration = self . config . get ( 'duration' ) #NEWLINE# pool = multiprocessing . Pool ( concurrency ) #NEWLINE# run_args = butils . infinite_run_args_generator ( self . _iter_scenario_args ( cls , method , context , args , self . aborted ) ) #NEWLINE# iter_result = pool . imap ( _run_scenario_once_with_unpack_args , run_args ) #NEWLINE# start = time . time ( ) #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# result = iter_result . next ( timeout ) #NEWLINE# #UNINDENT# except multiprocessing . TimeoutError as e : #NEWLINE# #INDENT# result = runner . format_result_on_timeout ( e , timeout ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# self . _send_result ( result ) #NEWLINE# if ( ( time . time ( ) - start ) > duration ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# pool . terminate ( ) #NEWLINE# pool . join ( ) #NEWLINE# self . _flush_results ( )