Skip to content

Commit

Permalink
Manually close db connections after call_command.
Browse files Browse the repository at this point in the history
  • Loading branch information
glogiotatidis committed May 16, 2016
1 parent 837252d commit 6415161
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/cron.py
Expand Up @@ -5,6 +5,7 @@

from django.core.management import call_command
from django.conf import settings
from django.db import connections

import requests
from apscheduler.schedulers.blocking import BlockingScheduler
Expand Down Expand Up @@ -64,6 +65,9 @@ def job_update_product_details():
call_command('update_product_details')
create_countries()
create_locales()
# Django won't close db connections after call_command. Close them manually
# to prevent errors in case the DB goes away, e.g. during a failover event.
connections.close_all()


def run():
Expand Down

0 comments on commit 6415161

Please sign in to comment.