(lock_file: str)
| 29 | |
| 30 | @pytest.mark.timeout(PROCESS_DEADLINE * 5) |
| 31 | def 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) |
nothing calls this directly
no test coverage detected