mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
Send more than one heartbeat message (#6418)
* Send heartbeat * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
727ae25976
commit
bce6ca109f
5
.changeset/whole-bears-rescue.md
Normal file
5
.changeset/whole-bears-rescue.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Send more than one heartbeat message
|
@ -642,7 +642,10 @@ class App(FastAPI):
|
||||
await asyncio.sleep(check_rate)
|
||||
if time.perf_counter() - last_heartbeat > heartbeat_rate:
|
||||
message = {"msg": "heartbeat"}
|
||||
last_heartbeat = time.time()
|
||||
# Need to reset last_heartbeat with perf_counter
|
||||
# otherwise only a single hearbeat msg will be sent
|
||||
# and then the stream will retry leading to infinite queue 😬
|
||||
last_heartbeat = time.perf_counter()
|
||||
|
||||
if message:
|
||||
yield f"data: {json.dumps(message)}\n\n"
|
||||
|
Loading…
Reference in New Issue
Block a user