Spaces:
Paused
Paused
feat: Suppress asyncio event loop warnings on HF Spaces shutdown
Browse files11 unmodified lines12131415161718192021222324252627282911 unmodified lineswarnings.filterwarnings("ignore", message=".*Invalid file descriptor.*")logging.getLogger("asyncio").setLevel(logging.CRITICAL)
# Suppress "Exception ignored in: BaseEventLoop.__del__" on HF Spaces shutdown# warnings.filterwarnings does NOT catch these — they go via sys.unraisablehook_original_unraisablehook = sys.unraisablehook
def _suppress_asyncio_fd_errors(unraisable): if (unraisable.exc_type is ValueError and "Invalid file descriptor" in str(unraisable.exc_value)): return # silently ignore _original_unraisablehook(unraisable)
sys.unraisablehook = _suppress_asyncio_fd_errors
# Set environment for Hugging Face Spacesos.environ['GRADIO_SERVER_NAME'] = '0.0.0.0'os.environ['GRADIO_SERVER_PORT'] = '7860'app.py+12