MCPcopy Create free account
hub / github.com/FastLED/FastLED / test_read_lock_shared

Method test_read_lock_shared

ci/tests/test_lock_database.py:83–101  ·  view source on GitHub ↗

Multiple PIDs can hold read locks simultaneously.

(self)

Source from the content-addressed store, hash-verified

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
104class TestWriteLockExclusive(unittest.TestCase):

Callers

nothing calls this directly

Calls 2

get_lock_infoMethod · 0.80
try_acquireMethod · 0.45

Tested by

no test coverage detected