MCPcopy Create free account
hub / github.com/cppla/moto / run_phase

Function run_phase

test/bench.py:145–162  ·  view source on GitHub ↗
(phase_name: str, concurrency: int, total: int,
                    timeout: float, jitter: float, results: List[Result])

Source from the content-addressed store, hash-verified

143 return out
144
145async def run_phase(phase_name: str, concurrency: int, total: int,
146 timeout: float, jitter: float, results: List[Result]):
147 sem = asyncio.Semaphore(concurrency)
148 started = 0
149
150 async def worker(idx: int):
151 nonlocal started
152 async with sem:
153 if jitter > 0:
154 await asyncio.sleep(random.random()*jitter)
155 res = await socks5_http_get(timeout, phase_name)
156 results.append(res)
157
158 tasks = []
159 for i in range(total):
160 started += 1
161 tasks.append(asyncio.create_task(worker(i)))
162 await asyncio.gather(*tasks)
163
164def summarize(results: List[Result]):
165 ok = [r for r in results if r.ok]

Callers 1

mainFunction · 0.85

Calls 1

workerFunction · 0.85

Tested by

no test coverage detected