fix(thread-safety): lock disc_entries reads/writes in HookServer, remove debug logs
This commit is contained in:
@@ -34,8 +34,10 @@ class HookHandler(BaseHTTPRequestHandler):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.end_headers()
|
||||
with app._disc_entries_lock:
|
||||
entries_snapshot = list(app.disc_entries)
|
||||
self.wfile.write(
|
||||
json.dumps({'session': {'entries': app.disc_entries}}).
|
||||
json.dumps({'session': {'entries': entries_snapshot}}).
|
||||
encode('utf-8'))
|
||||
elif self.path == '/api/performance':
|
||||
self.send_response(200)
|
||||
@@ -211,7 +213,8 @@ class HookHandler(BaseHTTPRequestHandler):
|
||||
self.send_response(500)
|
||||
self.end_headers()
|
||||
elif self.path == '/api/session':
|
||||
app.disc_entries = data.get('session', {}).get('entries', app.disc_entries)
|
||||
with app._disc_entries_lock:
|
||||
app.disc_entries = data.get('session', {}).get('entries', app.disc_entries)
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.end_headers()
|
||||
|
||||
Reference in New Issue
Block a user