Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,9 +7,31 @@ import os
|
|
| 7 |
import sys
|
| 8 |
import threading
|
| 9 |
import time
|
|
|
|
| 10 |
from datetime import datetime, timedelta
|
| 11 |
from typing import Any
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
import gradio as gr
|
| 14 |
|
| 15 |
|
|
|
|
| 7 |
import sys
|
| 8 |
import threading
|
| 9 |
import time
|
| 10 |
+
import warnings
|
| 11 |
from datetime import datetime, timedelta
|
| 12 |
from typing import Any
|
| 13 |
|
| 14 |
+
# Suppress asyncio event loop cleanup errors (Python 3.10 issue on HF Spaces)
|
| 15 |
+
# These occur when event loops are garbage collected after file descriptors close
|
| 16 |
+
def _patch_asyncio_event_loop_del():
|
| 17 |
+
"""Patch BaseEventLoop.__del__ to suppress 'Invalid file descriptor: -1' errors."""
|
| 18 |
+
try:
|
| 19 |
+
import asyncio.base_events as base_events
|
| 20 |
+
original_del = getattr(base_events.BaseEventLoop, "__del__", None)
|
| 21 |
+
if original_del is None:
|
| 22 |
+
return
|
| 23 |
+
def patched_del(self):
|
| 24 |
+
try:
|
| 25 |
+
original_del(self)
|
| 26 |
+
except ValueError as e:
|
| 27 |
+
if "Invalid file descriptor" not in str(e):
|
| 28 |
+
raise
|
| 29 |
+
base_events.BaseEventLoop.__del__ = patched_del
|
| 30 |
+
except Exception:
|
| 31 |
+
pass
|
| 32 |
+
|
| 33 |
+
_patch_asyncio_event_loop_del()
|
| 34 |
+
|
| 35 |
import gradio as gr
|
| 36 |
|
| 37 |
|