trx/udp_link.py: close socket in destructor

Previously it was required to call the UDPLink.shutdown() method
manually in order to close a socket. Let's do it automatically
using the destructor of UDPLink.

Cherry-picked from: I59c3dc61ec58cd9effeb789947d28fd602ca91f4
Change-Id: Ief7aa21d1e50682a90616833b679741957193aae
This commit is contained in:
Vadim Yanitskiy 2018-08-09 19:17:57 +07:00
parent 8e1fa8bdd7
commit bf6f6ec0de
3 changed files with 3 additions and 8 deletions

View File

@ -83,7 +83,6 @@ class Application:
def shutdown(self):
print("[i] Shutting down...")
self.server.shutdown()
self.radio.shutdown()
def print_copyright(self):

View File

@ -35,10 +35,6 @@ class ctrl_if_bb(ctrl_if):
# Power measurement
self.pm = pm
def shutdown(self):
print("[i] Shutdown CTRL interface")
ctrl_if.shutdown(self)
def parse_cmd(self, request):
# Power control
if self.verify_cmd(request, "POWERON", 0):

View File

@ -35,6 +35,9 @@ class udp_link:
self.remote_addr = remote_addr
self.remote_port = remote_port
def __del__(self):
self.sock.close()
def loop(self):
r_event, w_event, x_event = select.select([self.sock], [], [])
@ -43,9 +46,6 @@ class udp_link:
data, addr = self.sock.recvfrom(128)
self.handle_rx(data.decode())
def shutdown(self):
self.sock.close();
def send(self, data):
if type(data) not in [bytearray, bytes]:
data = data.encode()