'poor mans's DB lock: lock the right DB

See #252 where the following error was triggered:

> django.db.transaction.TransactionManagementError: select_for_update cannot be
> used outside of a transaction.

I believe that this is caused by using a non-sqlite database for the snappea DB.
"You probably shouldn't" but at least our own behavior should be consistent.

I haven't been able to reproduce this particular error BTW, but at least I've
reproduced _some_ error conditions that this commit fixes.
This commit is contained in:
Klaas van Schelven
2025-10-23 21:54:57 +02:00
parent dcaa1d5e72
commit e55c0eb417

View File

@@ -172,7 +172,7 @@ class ImmediateAtomic(SuperDurableAtomic):
# like very much that we stick closely to the sqlite model for the mysql case, but we can always take this
# road later.
from django.contrib.contenttypes.models import ContentType
ContentType.objects.select_for_update().order_by("pk").first()
ContentType.objects.using(self.using).select_for_update().order_by("pk").first()
self.t0 = time.time()