

def main(options, mode, url):
    start_time = time.time()
    errors = 0
    if (mode == 'parallel'):
        nrequests_per_thread = (options.nrequests / options.nthreads)
        if options.verbose:
            print(('Getting %s %s times total in %s threads, %s times per thread' % (url, (nrequests_per_thread * options.nthreads), options.nthreads, nrequests_per_thread)))
        threads = [URLGetterThread(options, url, nrequests_per_thread) for _ in range(options.nthreads)]
        for t in threads:
            t.start()
        for t in threads:
            t.join()
        errors = sum([t.errors for t in threads])
        nthreads_with_errors = len([t for t in threads if t.errors])
        if nthreads_with_errors:
            print(('%d threads had errors! %d errors in total' % (nthreads_with_errors, errors)))
    else:
        assert (mode == 'serial')
        if options.verbose:
            print(('Getting %s %s times in one thread' % (url, options.nrequests)))
        for i in range(1, (options.nrequests + 1)):
            try:
                get(url)
            except Exception as e:
                print(e)
                if (not options.continue_):
                    sys.exit(1)
                errors += 1
            if (options.verbose and (not (i % 1000))):
                print(i)
        if errors:
            print(('%d errors!' % errors))
    if options.verbose:
        print(('Completed in %.2f seconds' % (time.time() - start_time)))
    if errors:
        sys.exit(1)

dataset/ETHPy150Open mongodb/mongo-python-driver/test/mod_wsgi_test/test_client.py main/original