We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a7ba4f commit e6a313dCopy full SHA for e6a313d
tests/test_core_lock.py
@@ -88,3 +88,26 @@ def test_rlock_block(this_lock):
88
89
# Release lock, assert no owner
90
assert not this_lock._is_owned()
91
+
92
+def test_rlock_acquire_timeout(this_lock):
93
+ from labthings.core.exceptions import LockError
94
95
+ # Acquire lock
96
+ assert this_lock.acquire()
97
98
+ # Override owner to force acquisition failure
99
+ this_lock._owner = None
100
+ print(this_lock._owner)
101
+ # Assert not owner
102
+ assert not this_lock._is_owned()
103
104
+ # Assert acquisition fails using context manager
105
+ with pytest.raises(LockError):
106
+ with this_lock.acquire_timeout(0.01):
107
+ pass
108
109
+ # Force ownership
110
+ this_lock._owner = getcurrent()
111
112
+ # Release lock
113
+ this_lock.release()
0 commit comments