Dooratre commited on
Commit
021f2f0
·
verified ·
1 Parent(s): f667251

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -250,13 +250,30 @@ def mid_price(bid: float, ask: float) -> float:
250
  return (bid + ask) / 2.0
251
 
252
  # ================ External orchestration ================
253
- def call_stop_analysis_and_clear_others():
 
254
  try:
255
- requests.get(ANALYSIS_STOP_URL, timeout=5)
 
 
 
 
 
 
 
 
 
 
256
  except Exception as e:
257
- logger.warning(f"[ANALYSIS] stop_analysis failed: {e}")
 
 
258
  try:
259
- requests.get(OTHER_ALERT_CLEAR_URL, timeout=5)
 
 
 
 
260
  except Exception as e:
261
  logger.warning(f"[ALERT] clear failed: {e}")
262
 
 
250
  return (bid + ask) / 2.0
251
 
252
  # ================ External orchestration ================
253
+ def call_stop_analysis_and_clear_others(session_id="default"):
254
+ # Stop analysis with proper POST + JSON payload
255
  try:
256
+ headers = {"Content-Type": "application/json", "Accept": "application/json"}
257
+ payload = {"session_id": str(session_id)}
258
+ resp = requests.post(ANALYSIS_STOP_URL, headers=headers, json=payload, timeout=8)
259
+ try:
260
+ body = resp.json()
261
+ except Exception:
262
+ body = {"raw_text": resp.text[:300]}
263
+ if resp.status_code != 200 or not body.get("success", False):
264
+ logger.warning(f"[ANALYSIS] stop_analysis returned {resp.status_code}: {body}")
265
+ else:
266
+ logger.info(f"[ANALYSIS] stop_analysis OK: {body.get('message','')}")
267
  except Exception as e:
268
+ logger.warning(f"[ANALYSIS] stop_analysis request failed: {e}")
269
+
270
+ # Clear other alerts (kept as GET unless your endpoint needs POST)
271
  try:
272
+ resp2 = requests.get(OTHER_ALERT_CLEAR_URL, timeout=5)
273
+ if resp2.status_code != 200:
274
+ logger.warning(f"[ALERT] clear returned {resp2.status_code}: {resp2.text[:200]}")
275
+ else:
276
+ logger.info("[ALERT] clear OK")
277
  except Exception as e:
278
  logger.warning(f"[ALERT] clear failed: {e}")
279