Piotr Krysik has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10421 )

Change subject: trx/udp_link.py: close socket in destructor
......................................................................

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
---
M apps/grgsm_trx
M python/trx/ctrl_if_bb.py
M python/trx/udp_link.py
3 files changed, 3 insertions(+), 8 deletions(-)

Approvals:
  Piotr Krysik: Looks good to me, approved; Verified



diff --git a/apps/grgsm_trx b/apps/grgsm_trx
index b925fc1..668b0be 100755
--- a/apps/grgsm_trx
+++ b/apps/grgsm_trx
@@ -83,7 +83,6 @@

        def shutdown(self):
                print("[i] Shutting down...")
-               self.server.shutdown()
                self.radio.shutdown()

        def print_copyright(self):
diff --git a/python/trx/ctrl_if_bb.py b/python/trx/ctrl_if_bb.py
index 5874e59..7886e23 100644
--- a/python/trx/ctrl_if_bb.py
+++ b/python/trx/ctrl_if_bb.py
@@ -35,10 +35,6 @@
                # 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):
diff --git a/python/trx/udp_link.py b/python/trx/udp_link.py
index 675ef5c..cedcb1b 100644
--- a/python/trx/udp_link.py
+++ b/python/trx/udp_link.py
@@ -35,6 +35,9 @@
                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 @@
                        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()

--
To view, visit https://gerrit.osmocom.org/10421
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: gr-gsm
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ief7aa21d1e50682a90616833b679741957193aae
Gerrit-Change-Number: 10421
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy <axilira...@gmail.com>
Gerrit-Reviewer: Piotr Krysik <ptrkry...@gmail.com>

Reply via email to