File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import os
44import signal
55import sys
6+ import threading
67from datetime import datetime
78
89from flask import Flask , jsonify , render_template
1213app = Flask (__name__ )
1314
1415logger = logging .getLogger (__name__ )
16+ status_lock = threading .Lock () # Initialize a lock for issue_statuses.json
1517data_parser_instance = DataParser () # Initialize DataParser once globally
1618
1719
@@ -61,9 +63,10 @@ def acknowledge_issue(issue_id):
6163 try :
6264 status_file = "issue_statuses.json"
6365 issue_statuses = {}
64- if os .path .exists (status_file ):
65- with open (status_file , "r" , encoding = "utf-8" ) as f :
66- issue_statuses = json .load (f )
66+ with status_lock : # Acquire lock before reading/writing shared resource
67+ if os .path .exists (status_file ):
68+ with open (status_file , "r" , encoding = "utf-8" ) as f :
69+ issue_statuses = json .load (f )
6770
6871 # Update status for the given issue_id
6972 issue_statuses [issue_id ] = {
You can’t perform that action at this time.
0 commit comments