From 4f674996e1b459484ef0c01c6ed9dab7de324a82 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Mon, 22 Jan 2024 17:39:53 +0545 Subject: [PATCH] Fix bug of removing layer inside thread --- backend/core/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/core/utils.py b/backend/core/utils.py index 3c09b559..82a403a8 100644 --- a/backend/core/utils.py +++ b/backend/core/utils.py @@ -192,7 +192,6 @@ def process_feature(feature, aoi_id, foreign_key_id, feedback=False): tags = properties["tags"] geometry = feature["geometry"] if feedback: - FeedbackLabel.objects.filter(aoi__id=aoi_id).delete() if FeedbackLabel.objects.filter( osm_id=int(osm_id), feedback_aoi__training=foreign_key_id ).exists(): @@ -210,7 +209,6 @@ def process_feature(feature, aoi_id, foreign_key_id, feedback=False): ) else: - Label.objects.filter(aoi__id=aoi_id).delete() if Label.objects.filter( osm_id=int(osm_id), aoi__dataset=foreign_key_id ).exists(): @@ -247,7 +245,10 @@ def process_geojson(geojson_file_path, aoi_id, feedback=False): max_workers = ( (os.cpu_count() - 1) if os.cpu_count() != 1 else 1 ) # leave one cpu free always - + if feedback: + FeedbackLabel.objects.filter(aoi__id=aoi_id).delete() + else : + Label.objects.filter(aoi__id=aoi_id).delete() # max_workers = os.cpu_count() # get total cpu count available on the with open(geojson_file_path) as f: