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

Function test_read_locks_are_shared

tests/sqlite/test_lock_contention.py:31–52  ·  view source on GitHub ↗
(lock_file: str)

Source from the content-addressed store, hash-verified

29
30@pytest.mark.timeout(PROCESS_DEADLINE * 5)
31def test_read_locks_are_shared(lock_file: str) -> None:
32 read1_acquired = Event()
33 read2_acquired = Event()
34 release_read1 = Event()
35 release_read2 = Event()
36
37 reader1 = Process(target=acquire_lock, args=(lock_file, "read", read1_acquired, release_read1))
38 reader2 = Process(target=acquire_lock, args=(lock_file, "read", read2_acquired, release_read2))
39
40 with cleanup_processes([reader1, reader2]):
41 reader1.start()
42 assert read1_acquired.wait(timeout=PROCESS_DEADLINE), f"First read lock not acquired on {lock_file}"
43 reader2.start()
44
45 assert read2_acquired.wait(timeout=PROCESS_DEADLINE), f"Second read lock not acquired on {lock_file}"
46
47 release_read1.set()
48 release_read2.set()
49 reader1.join(timeout=PROCESS_DEADLINE)
50 reader2.join(timeout=PROCESS_DEADLINE)
51 assert not reader1.is_alive(), "Reader 1 did not exit cleanly"
52 assert not reader2.is_alive(), "Reader 2 did not exit cleanly"
53
54
55@pytest.mark.timeout(PROCESS_DEADLINE * 5)

Callers

nothing calls this directly

Calls 3

cleanup_processesFunction · 0.90
waitMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected