Multiple PIDs can hold read locks simultaneously.
(self)
| 81 | shutil.rmtree(self.temp_dir, ignore_errors=True) |
| 82 | |
| 83 | def test_read_lock_shared(self) -> None: |
| 84 | """Multiple PIDs can hold read locks simultaneously.""" |
| 85 | pid1 = os.getpid() |
| 86 | # Use a fake PID for the second reader (simulated) |
| 87 | pid2 = pid1 + 99999 |
| 88 | |
| 89 | acquired1 = self.db.try_acquire( |
| 90 | "shared_lock", pid1, "localhost", "reader1", mode="read" |
| 91 | ) |
| 92 | self.assertTrue(acquired1) |
| 93 | |
| 94 | acquired2 = self.db.try_acquire( |
| 95 | "shared_lock", pid2, "localhost", "reader2", mode="read" |
| 96 | ) |
| 97 | self.assertTrue(acquired2) |
| 98 | |
| 99 | # Both should be held |
| 100 | holders = self.db.get_lock_info("shared_lock") |
| 101 | self.assertEqual(len(holders), 2) |
| 102 | |
| 103 | |
| 104 | class TestWriteLockExclusive(unittest.TestCase): |
nothing calls this directly
no test coverage detected