Skip to content

Commit

Permalink
data_quality: rewrite_quality_data: Close db connection in thread
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwood committed Jun 16, 2021
1 parent ec7bc5b commit c6b83ec
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.management.base import BaseCommand
from django.core.cache import cache
from django.db import connection

from data_quality import quality_data
import db.models as db
Expand Down Expand Up @@ -45,6 +46,7 @@ def process_source_file(source_file):
grants_list
)
source_file.save()
connection.close()

with Pool(4) as process_pool:
process_pool.starmap(process_source_file, zip(source_files))
Expand All @@ -66,6 +68,7 @@ def process_publishers(source_file):
publisher.aggregate = ret["aggregate"]
publisher.quality = ret["quality"]
publisher.save()
connection.close()

# for source_file in source_files.distinct("data__publisher__prefix"):
# process_publishers(source_file)
Expand Down

0 comments on commit c6b83ec

Please sign in to comment.