Spaces:
Runtime error
Runtime error
File size: 890 Bytes
eeb0f9c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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.") |