def worker(test_queue, done_queue, worker_id, addr, authkey): """This is used by concurrent test processes. It takes a test off of the test_queue, runs it, then puts the Test object on the done_queue. """ if addr is None: server = None else: server = get_client_manager(addr, authkey) # need a unique profile output file for each worker process testflo.profile._prof_file = 'profile_%s.out' % worker_id test_count = 0 for test in iter(test_queue.get, 'STOP'): try: test_count += 1 done_queue.put(test.run(server, addr, authkey)) except: # we generally shouldn't get here, but just in case, # handle it so that the main process doesn't hang at the # end when it tries to join all of the concurrent processes. done_queue.put(test) # don't save anything unless we actually ran a test if test_count > 0: save_coverage() save_profile()
def worker(runner, test_queue, done_queue, worker_id): """This is used by concurrent test processes. It takes a test off of the test_queue, runs it, then puts the TestResult object on the done_queue. """ # need a unique profile output file for each worker process testflo.profile._prof_file = "profile_%s.out" % worker_id test_count = 0 for testspec in iter(test_queue.get, "STOP"): try: test_count += 1 done_queue.put(runner.run_testspec(testspec)) except: # we generally shouldn't get here, but just in case, # handle it so that the main process doesn't hang at the # end when it tries to join all of the concurrent processes. done_queue.put(TestResult(testspec, 0.0, 0.0, "FAIL", traceback.format_exc())) # don't save anything unless we actually ran a test if test_count > 0: save_coverage() save_profile()