AstraOS commited on
Commit
db81160
·
verified ·
1 Parent(s): 9dd116d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -161,10 +161,10 @@ def validate_inputs():
161
  def live_log_updater(chat_id):
162
  global live_log_message_id, streaming_state
163
  try:
164
- # Send initial live log message
165
  payload = {
166
  "chat_id": chat_id,
167
- "text": "*Live Logs:*\n_(Initializing...)_",
168
  "parse_mode": "Markdown"
169
  }
170
  resp = requests.post(f"{TELEGRAM_API_URL}/sendMessage", json=payload)
@@ -175,7 +175,7 @@ def live_log_updater(chat_id):
175
  logging.error("Failed to send live log message.")
176
  return
177
 
178
- # Update live log every 3 seconds until streaming stops
179
  while streaming_state in ["streaming", "paused"]:
180
  log_text = "*Live Logs:*\n\n" + "\n".join(live_log_lines[-15:]) # show last 15 lines
181
  edit_payload = {
@@ -185,7 +185,7 @@ def live_log_updater(chat_id):
185
  "parse_mode": "Markdown"
186
  }
187
  requests.post(f"{TELEGRAM_API_URL}/editMessageText", json=edit_payload)
188
- time.sleep(3)
189
  except Exception as e:
190
  logging.error(f"Error in live log updater: {e}")
191
 
@@ -392,7 +392,7 @@ def start_streaming(chat_id):
392
  stream_thread.start()
393
  logging.info("Streaming thread started.")
394
 
395
- # Start the live log updater thread
396
  live_log_thread = threading.Thread(target=live_log_updater, args=(chat_id,))
397
  live_log_thread.daemon = True
398
  live_log_thread.start()
 
161
  def live_log_updater(chat_id):
162
  global live_log_message_id, streaming_state
163
  try:
164
+ # Send initial live log message immediately upon starting the stream
165
  payload = {
166
  "chat_id": chat_id,
167
+ "text": "*Live Logs:*\n_(Initializing real-time logs...)_",
168
  "parse_mode": "Markdown"
169
  }
170
  resp = requests.post(f"{TELEGRAM_API_URL}/sendMessage", json=payload)
 
175
  logging.error("Failed to send live log message.")
176
  return
177
 
178
+ # Update live log every 5 seconds until streaming stops
179
  while streaming_state in ["streaming", "paused"]:
180
  log_text = "*Live Logs:*\n\n" + "\n".join(live_log_lines[-15:]) # show last 15 lines
181
  edit_payload = {
 
185
  "parse_mode": "Markdown"
186
  }
187
  requests.post(f"{TELEGRAM_API_URL}/editMessageText", json=edit_payload)
188
+ time.sleep(5)
189
  except Exception as e:
190
  logging.error(f"Error in live log updater: {e}")
191
 
 
392
  stream_thread.start()
393
  logging.info("Streaming thread started.")
394
 
395
+ # Start the live log updater thread (updates every 5 seconds for real-time logs)
396
  live_log_thread = threading.Thread(target=live_log_updater, args=(chat_id,))
397
  live_log_thread.daemon = True
398
  live_log_thread.start()