Refactor main function and related methods to remove async/await, replacing with synchronous calls for improved performance and simplicity

This commit is contained in:
Nawaz Haider
2026-01-12 21:43:00 +06:00
parent da9244eabd
commit 5a579d49c0
5 changed files with 81 additions and 66 deletions
+30
View File
@@ -0,0 +1,30 @@
import asyncio
from concurrent.futures import ThreadPoolExecutor
import time
async def test():
return
loop = asyncio.get_event_loop()
times = []
for _ in range(1000):
start = time.time()
with ThreadPoolExecutor(max_workers=2) as executor:
tasks = [
loop.run_in_executor(executor, test),
loop.run_in_executor(
executor,
test,
),
]
await asyncio.gather(*tasks)
end = time.time()
times.append(end - start)
sum(times)