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

Function holding_reader

tests/sqlite/process_support.py:58–74  ·  view source on GitHub ↗
(database: Path)

Source from the content-addressed store, hash-verified

56
57@contextmanager
58def holding_reader(database: Path) -> Generator[subprocess.Popen[str]]: # pragma: needs sqlite-private-link
59 script: Final[str] = (
60 "import sys, time\n"
61 "from filelock import ReadWriteLock\n"
62 "lock = ReadWriteLock(sys.argv[1], is_singleton=False)\n"
63 "lock.acquire_read()\n"
64 "print('held', flush=True)\n"
65 "time.sleep(600)\n"
66 )
67 with subprocess.Popen([sys.executable, "-c", script, str(database)], stdout=subprocess.PIPE, text=True) as holder:
68 try:
69 assert holder.stdout is not None
70 assert holder.stdout.readline() == "held\n"
71 yield holder
72 finally:
73 holder.kill()
74 holder.wait(timeout=30)
75
76
77def grant_everyone_write(directory: Path) -> None: # pragma: win32 cover

Callers 2

posix_link_holderFunction · 0.90
windows_link_holderFunction · 0.90

Calls 1

waitMethod · 0.80

Tested by 2

posix_link_holderFunction · 0.72
windows_link_holderFunction · 0.72