From 25f7c334f6297719b7a84510a9e8ff8cdda9255a Mon Sep 17 00:00:00 2001 From: Rusty Brooks Date: Thu, 19 Dec 2024 21:49:42 -0600 Subject: [PATCH] attempt to fix sync.py --- src/api/bikes/management/commands/sync.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/bikes/management/commands/sync.py b/src/api/bikes/management/commands/sync.py index a43c987..47a438e 100644 --- a/src/api/bikes/management/commands/sync.py +++ b/src/api/bikes/management/commands/sync.py @@ -2,6 +2,7 @@ import logging import time +import django.db from django.contrib.auth.models import User from django.core.management.base import BaseCommand @@ -26,6 +27,7 @@ def handle(self, *args, **options): while True: try: t1 = time.time() + django.db.close_old_connections() for user in User.objects.all(): last_act = ( StravaActivity.objects.filter(user=user) @@ -59,6 +61,7 @@ def handle(self, *args, **options): outcomes.append(1) if sum(outcomes[-10:]) >= 10: logger.error("10 exceptions in a row, bailing") + break time.sleep(30)