| 93 | finished: list[None] = [] |
| 94 | |
| 95 | def work(lock: BaseFileLock) -> None: |
| 96 | name = threading.current_thread().name |
| 97 | for _ in range(100): |
| 98 | with lock: |
| 99 | holders.append(name) |
| 100 | # GraalPy handles integer zero and float zero differently. |
| 101 | time.sleep(0.0) # give up the GIL so an overlapping holder has a chance to show in the slot |
| 102 | assert holders == [name] |
| 103 | assert lock.is_locked |
| 104 | holders.pop() |
| 105 | finished.append(None) |
| 106 | |
| 107 | lock_path = tmp_path / "a" |
| 108 | lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path)) |