Exemplo n.º 1
0
def test_repeat():
    rail_gun = Railgun(semaphores_count=5, loop=get_event_loop())
    repeats = rail_gun.repeat(example_method_one, [1, 2], repeat=10)

    assert len(repeats) == 10
    assert repeats[0] == 3
Exemplo n.º 2
0
def test_repeat_api_call():
    rail_gun = Railgun(semaphores_count=5, loop=get_event_loop())
    results = rail_gun.repeat(example_call_api, ['www.google.com', '/'],
                              repeat=5)
    assert len(results) == 5
    assert results[0] == 200
Exemplo n.º 3
0
    return status_code


# tasks = [random_task(5,10), random_task(1,1), random_task(2,5), random_task_async(6,3)]

tasks = [call_web()] * 100
print('before railgun')
rail_gun = Railgun(semaphores_count=500)
# time.sleep(3)
print('After rail gun')
# test = rail_gun.run(tasks)
print('After rail gun run')

# print(test)
# print(f'len of returns {len(test)}')
loop = asyncio.get_event_loop()
async_tasks_1 = []
async_tasks_2 = []
start = time.time()
# for x in range(0, 299):
#     async_tasks_1.append(call_web_async())
#     async_tasks_2.append(call_web_async())
print(f'after for loop: {time.time() - start}')


async_test_3 = rail_gun.repeat(random_task, [12, 0.01], 200)
print(async_test_3)
print(len(async_test_3))

start = time.time()