immediate_semaphore.acquire 10s timeout

as explained in the comment
This commit is contained in:
Klaas van Schelven
2025-02-06 14:24:06 +01:00
parent 415da94093
commit d0f2a0c686

View File

@@ -121,7 +121,11 @@ class ImmediateAtomic(SuperDurableAtomic):
# have the patched method; get_connection is thread_local, so monkey-patching is thread-safe.
def __enter__(self):
immediate_semaphore.acquire()
if not immediate_semaphore.acquire(timeout=10):
# "should never happen", but I'd rather have a clear error message than a silent deadlock; the timeout of 10
# is chosen to be longer than the DB-related timeouts. i.e. when this happens it's presumably an error in
# the locking mechanism specifically, not actually caused by the DB being busy.
raise RuntimeError("Could not acquire immediate_semaphore")
connection = django_db_transaction.get_connection(self.using)