From 0f65b19775c2ec9202ce4128d968f446a82f2185 Mon Sep 17 00:00:00 2001 From: Adrien Perrin Date: Tue, 26 Jan 2021 12:08:16 +0000 Subject: [PATCH] fix lost sychronisation errors by forcing the creation of a new database connection for each harvester process --- geospaas_harvesting/harvest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/geospaas_harvesting/harvest.py b/geospaas_harvesting/harvest.py index 457443e7..e92e3b29 100644 --- a/geospaas_harvesting/harvest.py +++ b/geospaas_harvesting/harvest.py @@ -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') @@ -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()