aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel O'Brien <sam.obrien@ni.com>2020-07-31 13:31:40 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2020-10-07 15:29:19 -0500
commit1bb603fffdbdcc87f7c26809d495ced7a5afc93b (patch)
tree5c6a3307b7c22b76129c1b2698df52955a0c1dc6
parenta37413055e4f72b03e3f988cea7ec2ac86590051 (diff)
downloaduhd-1bb603fffdbdcc87f7c26809d495ced7a5afc93b.tar.gz
uhd-1bb603fffdbdcc87f7c26809d495ced7a5afc93b.tar.bz2
uhd-1bb603fffdbdcc87f7c26809d495ced7a5afc93b.zip
mpm: Cleanup rpc_server.py
This commit fixes a spelling mistake, moves logic for checking if a connection is local to its own method, and calls gevent.signal.signal instead of its deprecated alias gevent.signal. Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
-rw-r--r--mpm/python/usrp_mpm/rpc_server.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py
index 65428f116..5d55c07e4 100644
--- a/mpm/python/usrp_mpm/rpc_server.py
+++ b/mpm/python/usrp_mpm/rpc_server.py
@@ -122,7 +122,7 @@ class MPMServer(RPCServer):
delattr(self, method)
else:
self.log.warning(
- "Attempted to remove non-existant method: %s",
+ "Attempted to remove non-existent method: %s",
method
)
self._db_methods = []
@@ -300,7 +300,7 @@ class MPMServer(RPCServer):
self._state.claim_token.value,
self.client_host
)
- if self.client_host in net.get_local_ip_addrs():
+ if _is_connection_local(self.client_host):
self.periph_manager.set_connection_type("local")
else:
self.periph_manager.set_connection_type("remote")
@@ -406,7 +406,7 @@ class MPMServer(RPCServer):
"""
info = self.periph_manager.get_device_info()
info["mpm_version"] = "{}.{}".format(*MPM_COMPAT_NUM)
- if self.client_host in net.get_local_ip_addrs():
+ if _is_connection_local(self.client_host):
info["connection"] = "local"
else:
info["connection"] = "remote"
@@ -543,6 +543,8 @@ class MPMServer(RPCServer):
self.log.debug("End of update_component")
self._reset_timer()
+def _is_connection_local(client_hostname):
+ return client_hostname in net.get_local_ip_addrs()
###############################################################################
# Process control
@@ -566,8 +568,8 @@ def _rpc_server_process(shared_state, port, default_args):
server.stop()
sys.exit(0)
threading.Thread(target=stop_worker, daemon=True).start()
- signal(signal.SIGTERM, lambda *args: stop_event.set())
- signal(signal.SIGINT, lambda *args: stop_event.set())
+ signal.signal(signal.SIGTERM, lambda *args: stop_event.set())
+ signal.signal(signal.SIGINT, lambda *args: stop_event.set())
server.serve_forever()