|
@@ -2,6 +2,7 @@ import asyncio
|
|
import gzip
|
|
import gzip
|
|
import json
|
|
import json
|
|
import re
|
|
import re
|
|
|
|
+import signal
|
|
from dataclasses import dataclass
|
|
from dataclasses import dataclass
|
|
from typing import Any, AsyncIterator, Dict, Optional
|
|
from typing import Any, AsyncIterator, Dict, Optional
|
|
from uuid import uuid4
|
|
from uuid import uuid4
|
|
@@ -161,6 +162,9 @@ class Air:
|
|
|
|
|
|
async def connect(self) -> None:
|
|
async def connect(self) -> None:
|
|
"""Connect to the NiceGUI On Air server."""
|
|
"""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:
|
|
if self.connecting:
|
|
return
|
|
return
|
|
self.connecting = True
|
|
self.connecting = True
|