(lock_file: str)
| 137 | |
| 138 | @pytest.mark.timeout(PROCESS_DEADLINE * 3) |
| 139 | def test_non_blocking_behavior(lock_file: str) -> None: |
| 140 | write_acquired = Event() |
| 141 | release_write = Event() |
| 142 | |
| 143 | writer = Process(target=acquire_lock, args=(lock_file, "write", write_acquired, release_write)) |
| 144 | |
| 145 | with cleanup_processes([writer]): |
| 146 | writer.start() |
| 147 | assert write_acquired.wait(timeout=PROCESS_DEADLINE), "Write lock not acquired" |
| 148 | |
| 149 | start_time = time.perf_counter() |
| 150 | |
| 151 | with pytest.raises(Timeout): |
| 152 | ReadWriteLock(lock_file).acquire_read(blocking=False) |
| 153 | |
| 154 | elapsed = time.perf_counter() - start_time |
| 155 | |
| 156 | assert elapsed < 0.1, f"Non-blocking took too long: {elapsed}s" |
| 157 | |
| 158 | release_write.set() |
| 159 | writer.join(timeout=PROCESS_DEADLINE) |
| 160 | |
| 161 | |
| 162 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected