Skip to content

Commit

Permalink
attempt to fix sync.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rustybrooks committed Dec 20, 2024
1 parent 339fe69 commit 25f7c33
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/api/bikes/management/commands/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 25f7c33

Please sign in to comment.