Update app.py
Browse files
app.py
CHANGED
@@ -500,8 +500,8 @@ def stream_logs():
|
|
500 |
def generate():
|
501 |
while True:
|
502 |
try:
|
503 |
-
# Get log message from queue, timeout
|
504 |
-
log_message = log_queue.get()
|
505 |
yield f"data: {log_message}\n\n"
|
506 |
except queue.Empty:
|
507 |
# Send a heartbeat to keep the connection alive
|
@@ -513,8 +513,4 @@ def stream_logs():
|
|
513 |
response.headers['Cache-Control'] = 'no-cache'
|
514 |
response.headers['Connection'] = 'keep-alive'
|
515 |
response.headers['Access-Control-Allow-Origin'] = '*'
|
516 |
-
return response
|
517 |
-
|
518 |
-
if __name__ == '__main__':
|
519 |
-
logger.info("Starting Flask API server...")
|
520 |
-
app.run(host='127.0.0.1', port=7860, debug=True, threaded=True)
|
|
|
500 |
def generate():
|
501 |
while True:
|
502 |
try:
|
503 |
+
# Get log message from queue, no timeout here, handling is done in the generator
|
504 |
+
log_message = log_queue.get(timeout=1) # Adding timeout of 1 second to avoid blocking indefinitely
|
505 |
yield f"data: {log_message}\n\n"
|
506 |
except queue.Empty:
|
507 |
# Send a heartbeat to keep the connection alive
|
|
|
513 |
response.headers['Cache-Control'] = 'no-cache'
|
514 |
response.headers['Connection'] = 'keep-alive'
|
515 |
response.headers['Access-Control-Allow-Origin'] = '*'
|
516 |
+
return response
|
|
|
|
|
|
|
|