| 47 | finished: list[None] = [] |
| 48 | |
| 49 | def thread_work() -> None: |
| 50 | name = threading.current_thread().name |
| 51 | for _ in range(10): |
| 52 | with lock: |
| 53 | holders.append(name) |
| 54 | # GraalPy handles integer zero and float zero differently. |
| 55 | time.sleep(0.0) # give up the GIL so an overlapping holder has a chance to show in the slot |
| 56 | assert holders == [name] |
| 57 | assert lock.is_locked |
| 58 | holders.pop() |
| 59 | finished.append(None) |
| 60 | |
| 61 | threads = [WorkerThread(target=thread_work, name=f"t{i}") for i in range(100)] |
| 62 | for thread in threads: |