(lock_file: str)
| 111 | |
| 112 | @pytest.mark.timeout(PROCESS_DEADLINE * 3) |
| 113 | def test_timeout_behavior(lock_file: str) -> None: |
| 114 | write_acquired = Event() |
| 115 | release_write = Event() |
| 116 | read_acquired = Event() |
| 117 | |
| 118 | writer = Process(target=acquire_lock, args=(lock_file, "write", write_acquired, release_write)) |
| 119 | reader = Process(target=acquire_lock, args=(lock_file, "read", read_acquired, None, 0.5, True)) |
| 120 | |
| 121 | with cleanup_processes([writer, reader]): |
| 122 | writer.start() |
| 123 | assert write_acquired.wait(timeout=PROCESS_DEADLINE), "Write lock not acquired" |
| 124 | |
| 125 | start_time = time.perf_counter() |
| 126 | reader.start() |
| 127 | |
| 128 | assert not read_acquired.wait(timeout=1), "Read lock should not be acquired" |
| 129 | reader.join(timeout=PROCESS_DEADLINE) |
| 130 | |
| 131 | elapsed = time.perf_counter() - start_time |
| 132 | assert 0.4 <= elapsed <= 10.0, f"Timeout was not respected: {elapsed}s" |
| 133 | |
| 134 | release_write.set() |
| 135 | writer.join(timeout=PROCESS_DEADLINE) |
| 136 | |
| 137 | |
| 138 | @pytest.mark.timeout(PROCESS_DEADLINE * 3) |
nothing calls this directly
no test coverage detected