added shutdown flag

pull/728/head
DJ2LS 2024-05-19 15:20:02 +02:00
parent c5bbed0267
commit c8f846e87b
1 changed files with 4 additions and 1 deletions

View File

@ -19,6 +19,7 @@ class radio:
self.connection = None
self.connected = False
self.shutdown = False
self.await_response = threading.Event()
self.await_response.set()
@ -42,7 +43,8 @@ class radio:
self.connect()
def connect(self):
if self.shutdown:
return
try:
self.connection = socket.create_connection((self.hostname, self.port), timeout=self.timeout)
self.connected = True
@ -54,6 +56,7 @@ class radio:
self.states.set_radio("radio_status", False)
def disconnect(self):
self.shutdown = True
self.connected = False
if self.connection:
self.connection.close()