MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / translate_async_sleeps

Function translate_async_sleeps

tools/synchro.py:348–361  ·  view source on GitHub ↗
(lines: list[str])

Source from the content-addressed store, hash-verified

346
347
348def translate_async_sleeps(lines: list[str]) -> list[str]:
349 blocking_sleeps = [line for line in lines if "asyncio.sleep(0)" in line]
350 lines = [line for line in lines if line not in blocking_sleeps]
351 sleeps = [line for line in lines if "asyncio.sleep" in line]
352
353 for line in sleeps:
354 res = re.search(r"asyncio\.sleep\(\s*(.*?)\)", line)
355 if res:
356 old = res[0]
357 index = lines.index(line)
358 new = f"time.sleep({res[1]})"
359 lines[index] = line.replace(old, new)
360
361 return lines
362
363
364def translate_docstrings(lines: list[str]) -> list[str]:

Callers 1

process_filesFunction · 0.85

Calls 1

indexMethod · 0.80

Tested by

no test coverage detected