Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -330,15 +330,25 @@ def image_to_video():
|
|
| 330 |
except ValueError as e:
|
| 331 |
return jsonify({'error': str(e)}), 400
|
| 332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
# Wait for workflow execution to complete
|
| 334 |
while True:
|
| 335 |
message = json.loads(ws.recv())
|
| 336 |
if message.get('type') == 'executing' and message['data']['node'] is None and message['data']['prompt_id'] == prompt_id:
|
| 337 |
break
|
| 338 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
# Fetch the complete history for the provided prompt_id
|
| 340 |
history = get_history(prompt_id, token).get(prompt_id, {})
|
| 341 |
-
print(f"History for prompt {prompt_id}: {history}")
|
| 342 |
|
| 343 |
video_data = None # Initialize video data
|
| 344 |
|
|
|
|
| 330 |
except ValueError as e:
|
| 331 |
return jsonify({'error': str(e)}), 400
|
| 332 |
|
| 333 |
+
|
| 334 |
+
# Wait for workflow execution to complete
|
| 335 |
+
last_ping = time.time() # Track the last ping time
|
| 336 |
+
PING_INTERVAL = 30 # Send a ping every 30 seconds
|
| 337 |
+
|
| 338 |
# Wait for workflow execution to complete
|
| 339 |
while True:
|
| 340 |
message = json.loads(ws.recv())
|
| 341 |
if message.get('type') == 'executing' and message['data']['node'] is None and message['data']['prompt_id'] == prompt_id:
|
| 342 |
break
|
| 343 |
+
|
| 344 |
+
# Send a ping if PING_INTERVAL has passed
|
| 345 |
+
if time.time() - last_ping > PING_INTERVAL:
|
| 346 |
+
ws.send('ping')
|
| 347 |
+
last_ping = time.time()
|
| 348 |
+
|
| 349 |
# Fetch the complete history for the provided prompt_id
|
| 350 |
history = get_history(prompt_id, token).get(prompt_id, {})
|
| 351 |
+
# print(f"History for prompt {prompt_id}: {history}")
|
| 352 |
|
| 353 |
video_data = None # Initialize video data
|
| 354 |
|