Skip to content

Commit

Permalink
fix lost sychronisation errors
Browse files Browse the repository at this point in the history
by forcing the creation of a new database connection
for each harvester process
  • Loading branch information
aperrin66 committed Jan 26, 2021
1 parent 9327bfa commit 0f65b19
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions geospaas_harvesting/harvest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import time
from datetime import datetime
import django
import django.db
import yaml
# Load Django settings to be able to interact with the database
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'geospaas_harvesting.settings')
Expand Down Expand Up @@ -196,6 +197,9 @@ def load_or_create_harvester(harvester_name, harvester_config, load_dumped=True)

def launch_harvest(harvester_name, harvester_config, dump_on_interruption=True):
"""Launch the harvest operation and process errors. Meant to be run in a separate process"""
# Force the creation of a new database connection for each new process
django.db.connection.close()

try:
harvester = load_or_create_harvester(harvester_name, harvester_config, dump_on_interruption)
harvester.harvest()
Expand Down

0 comments on commit 0f65b19

Please sign in to comment.