mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 18:40:47 +00:00
add timeout to response socket in updater
patch bump
This commit is contained in:
parent
14e538dca6
commit
444f95a9d6
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "vban-cmd"
|
name = "vban-cmd"
|
||||||
version = "1.4.2"
|
version = "1.4.3"
|
||||||
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
||||||
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -41,6 +41,7 @@ class Updater(threading.Thread):
|
|||||||
def __init__(self, remote):
|
def __init__(self, remote):
|
||||||
super().__init__(name="updater", target=self.update, daemon=True)
|
super().__init__(name="updater", target=self.update, daemon=True)
|
||||||
self._remote = remote
|
self._remote = remote
|
||||||
|
self._remote.socks[Socket.response].settimeout(5)
|
||||||
self._remote.socks[Socket.response].bind(
|
self._remote.socks[Socket.response].bind(
|
||||||
(socket.gethostbyname(socket.gethostname()), self._remote.port)
|
(socket.gethostbyname(socket.gethostname()), self._remote.port)
|
||||||
)
|
)
|
||||||
@ -48,6 +49,7 @@ class Updater(threading.Thread):
|
|||||||
self._remote._public_packet = self._get_rt()
|
self._remote._public_packet = self._get_rt()
|
||||||
|
|
||||||
def _fetch_rt_packet(self) -> Optional[VbanRtPacket]:
|
def _fetch_rt_packet(self) -> Optional[VbanRtPacket]:
|
||||||
|
try:
|
||||||
data, _ = self._remote.socks[Socket.response].recvfrom(2048)
|
data, _ = self._remote.socks[Socket.response].recvfrom(2048)
|
||||||
# check for packet data
|
# check for packet data
|
||||||
if len(data) > HEADER_SIZE:
|
if len(data) > HEADER_SIZE:
|
||||||
@ -77,6 +79,10 @@ class Updater(threading.Thread):
|
|||||||
_stripLabelUTF8c60=data[452:932],
|
_stripLabelUTF8c60=data[452:932],
|
||||||
_busLabelUTF8c60=data[932:1412],
|
_busLabelUTF8c60=data[932:1412],
|
||||||
)
|
)
|
||||||
|
except TimeoutError as e:
|
||||||
|
print(f"Unable to establish connection with {self._remote.ip}")
|
||||||
|
[sock.close() for sock in self._remote.socks]
|
||||||
|
raise e
|
||||||
|
|
||||||
def _get_rt(self) -> VbanRtPacket:
|
def _get_rt(self) -> VbanRtPacket:
|
||||||
"""Attempt to fetch data packet until a valid one found"""
|
"""Attempt to fetch data packet until a valid one found"""
|
||||||
|
Loading…
Reference in New Issue
Block a user