my-gradio-app / app.py
Nguyen Trong Lap
Recreate history without binary blobs
eeb0f9c
raw
history blame contribute delete
890 Bytes
from ui import build_ui
import signal
import sys
import os
def signal_handler(sig, frame):
"""Handle Ctrl+C gracefully"""
print("\n\n👋 Đang tắt server... Bye bye!")
# Use os._exit() instead of sys.exit() to avoid atexit callbacks
# This prevents the torch cleanup race condition warning
os._exit(0)
# Register signal handler
signal.signal(signal.SIGINT, signal_handler)
demo = build_ui()
if __name__ == "__main__":
try:
demo.queue().launch(
debug=False,
share=True,
show_api=False,
show_error=True,
quiet=False # Keep startup messages but hide processing time in UI
)
except KeyboardInterrupt:
print("\n\n👋 Server đã tắt. Hẹn gặp lại!")
except Exception as e:
print(f"\n❌ Lỗi: {e}")
finally:
print("✅ Cleanup hoàn tất.")