فهرست منبع

fix hanging reload when httpx range-requests are still open

Rodja Trappe 1 سال پیش
والد
کامیت
39bfd667fd
1فایلهای تغییر یافته به همراه4 افزوده شده و 0 حذف شده
  1. 4 0
      nicegui/air.py

+ 4 - 0
nicegui/air.py

@@ -2,6 +2,7 @@ import asyncio
 import gzip
 import json
 import re
+import signal
 from dataclasses import dataclass
 from typing import Any, AsyncIterator, Dict, Optional
 from uuid import uuid4
@@ -161,6 +162,9 @@ class Air:
 
     async def connect(self) -> None:
         """Connect to the NiceGUI On Air server."""
+        # ensure that the connection is closed when the process is terminated
+        signal.signal(signal.SIGINT, disconnect)
+        signal.signal(signal.SIGTERM, disconnect)
         if self.connecting:
             return
         self.connecting = True