gabejavitt commited on
Commit
bc1a487
·
verified ·
1 Parent(s): fe49a23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -12,6 +12,22 @@ Improvements:
12
  import gc
13
  import os
14
  import io
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  import subprocess
16
  import json
17
  import re
 
12
  import gc
13
  import os
14
  import io
15
+
16
+ # Workaround: Gradio 5.x bug where Queue.pending_message_lock stays None if the
17
+ # ASGI lifespan startup events don't fire (a Python 3.13 asyncio compatibility issue).
18
+ # Patch Queue.push to lazily initialize the lock before its first use.
19
+ try:
20
+ import asyncio as _asyncio
21
+ from gradio.queueing import Queue as _GradioQueue
22
+ _orig_push = _GradioQueue.push
23
+ async def _patched_push(self, *args, **kwargs):
24
+ if getattr(self, "pending_message_lock", None) is None:
25
+ self.pending_message_lock = _asyncio.Lock()
26
+ return await _orig_push(self, *args, **kwargs)
27
+ _GradioQueue.push = _patched_push
28
+ print("✅ Applied Gradio queue lock workaround")
29
+ except Exception as _patch_err:
30
+ print(f"ℹ️ Gradio queue patch skipped: {_patch_err}")
31
  import subprocess
32
  import json
33
  import re