mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-07 22:58:12 +08:00
Merge pull request #440 from maerteijn/fix-database-router
Fix issues when using multiple databases with a database router
This commit is contained in:
@@ -17,7 +17,7 @@ def _timeout():
|
|||||||
class ORM(Broker):
|
class ORM(Broker):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_connection(list_key=Conf.PREFIX):
|
def get_connection(list_key=Conf.PREFIX):
|
||||||
if transaction.get_autocommit(): # Only True when not in an atomic block
|
if transaction.get_autocommit(using=Conf.ORM): # Only True when not in an atomic block
|
||||||
# Make sure stale connections in the broker thread are explicitly
|
# Make sure stale connections in the broker thread are explicitly
|
||||||
# closed before attempting DB access.
|
# closed before attempting DB access.
|
||||||
# logger.debug("Broker thread calling close_old_connections")
|
# logger.debug("Broker thread calling close_old_connections")
|
||||||
|
|||||||
+1
-1
@@ -548,7 +548,7 @@ def scheduler(broker=None):
|
|||||||
broker = get_broker()
|
broker = get_broker()
|
||||||
close_old_django_connections()
|
close_old_django_connections()
|
||||||
try:
|
try:
|
||||||
with db.transaction.atomic():
|
with db.transaction.atomic(using=Schedule.objects.db):
|
||||||
for s in (
|
for s in (
|
||||||
Schedule.objects.select_for_update()
|
Schedule.objects.select_for_update()
|
||||||
.exclude(repeats=0)
|
.exclude(repeats=0)
|
||||||
|
|||||||
Reference in New Issue
Block a user