33 lines
869 B
Python
33 lines
869 B
Python
from app.inbox_locks import InboxRunLocks
|
|
|
|
|
|
def test_inbox_run_locks_serialize_different_inboxes():
|
|
locks = InboxRunLocks()
|
|
first = locks.acquire("first", blocking=False)
|
|
assert first is not None
|
|
|
|
try:
|
|
assert locks.acquire("second", blocking=False) is None
|
|
finally:
|
|
first.release()
|
|
|
|
second = locks.acquire("second", blocking=False)
|
|
assert second is not None
|
|
second.release()
|
|
|
|
|
|
def test_inbox_run_locks_serialize_across_lock_instances():
|
|
first_locks = InboxRunLocks()
|
|
second_locks = InboxRunLocks()
|
|
first = first_locks.acquire("first", blocking=False)
|
|
assert first is not None
|
|
|
|
try:
|
|
assert second_locks.acquire("second", blocking=False) is None
|
|
finally:
|
|
first.release()
|
|
|
|
second = second_locks.acquire("second", blocking=False)
|
|
assert second is not None
|
|
second.release()
|