MCPcopy Create free account
hub / github.com/tox-dev/filelock / write_repeatedly

Function write_repeatedly

tests/sqlite/test_async_contention.py:223–233  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

221 inside = peak = 0
222
223 async def write_repeatedly() -> None:
224 nonlocal inside, peak
225 lock = AsyncReadWriteLock(lock_file)
226 for _ in range(20):
227 async with lock.write_lock(timeout=TASK_WAIT):
228 with guard:
229 inside += 1
230 peak = max(peak, inside)
231 await asyncio.sleep(0)
232 with guard:
233 inside -= 1
234
235 threads = [threading.Thread(target=asyncio.run, args=(write_repeatedly(),), daemon=True) for _ in range(2)]
236 for thread in threads:

Calls 3

write_lockMethod · 0.95
AsyncReadWriteLockClass · 0.90
sleepMethod · 0.80

Tested by

no test coverage detected