update
This commit is contained in:
parent
84aa2a0637
commit
cb11e4bf38
@ -21,8 +21,6 @@ async def main(a_start, b_end, sigma):
|
|||||||
for i in range(num_chunks)]
|
for i in range(num_chunks)]
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
tasks = [send_request(client, server, rangee, sigma) for server, rangee in zip(ip_list, ranges)]
|
tasks = [send_request(client, server, rangee, sigma) for server, rangee in zip(ip_list, ranges)]
|
||||||
# tasks2 = [send_request(client, server, rangee, sigma) for server, rangee in zip(ip_list, ranges[16:32])]
|
|
||||||
# tasks.extend(tasks2)
|
|
||||||
results = await asyncio.gather(*tasks)
|
results = await asyncio.gather(*tasks)
|
||||||
final_result = 0
|
final_result = 0
|
||||||
for idx, result in enumerate(results):
|
for idx, result in enumerate(results):
|
||||||
|
12
main.py
12
main.py
@ -33,13 +33,11 @@ async def compute(data: ComputeInput):
|
|||||||
ranges = [(a_start + i * chunk_size, min(a_start + (i + 1) * chunk_size - 1, b_end))
|
ranges = [(a_start + i * chunk_size, min(a_start + (i + 1) * chunk_size - 1, b_end))
|
||||||
for i in range(num_chunks)]
|
for i in range(num_chunks)]
|
||||||
|
|
||||||
return ranges
|
with ThreadPoolExecutor() as executor:
|
||||||
#
|
futures = [executor.submit(run_compute, a, b, sigma) for a, b in ranges]
|
||||||
# with ThreadPoolExecutor() as executor:
|
results = [f.result() for f in futures]
|
||||||
# futures = [executor.submit(run_compute, a, b, sigma) for a, b in ranges]
|
|
||||||
# results = [f.result() for f in futures]
|
return sum(results) % 999999937
|
||||||
#
|
|
||||||
# return sum(results) % 999999937
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||||
|
Loading…
Reference in New Issue
Block a user