diff options
author | Toni Jones <toni.jones@ni.com> | 2020-03-02 17:52:09 -0600 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-03-04 12:13:13 -0600 |
commit | 5fc01186d30cd7aac83a65c804f936e32acdd0cf (patch) | |
tree | a6e62f49e06dfcd5c9253c7dd392ce0b2f106d81 /mpm | |
parent | 760071a0be8ae4820b3325db591254bca04a9a4f (diff) | |
download | uhd-5fc01186d30cd7aac83a65c804f936e32acdd0cf.tar.gz uhd-5fc01186d30cd7aac83a65c804f936e32acdd0cf.tar.bz2 uhd-5fc01186d30cd7aac83a65c804f936e32acdd0cf.zip |
mpm: rpc: Use contextmanager for claim timeouts
Modify the RPC claim timeout mechanism to use a contextmanager
helper function when enabling/disabling timeouts.
Diffstat (limited to 'mpm')
-rw-r--r-- | mpm/python/usrp_mpm/rpc_server.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py index de4989fbc..481b8e23a 100644 --- a/mpm/python/usrp_mpm/rpc_server.py +++ b/mpm/python/usrp_mpm/rpc_server.py @@ -519,16 +519,16 @@ class MPMServer(RPCServer): raise RuntimeError("Attempt to reset manager without valid claim.") # Stop the timer, reset_timer_and_mgr can take some time: - self._disable_timeouts = True - try: - self.reset_mgr() - self.log.debug("Reset the periph manager") - except Exception as ex: - self.log.error( - "Error in reset_timer_and_mgr: {}".format( - ex - )) - self._last_error = str(ex) + with self._timeout_disabler(): + try: + self.reset_mgr() + self.log.debug("Reset the periph manager") + except Exception as ex: + self.log.error( + "Error in reset_timer_and_mgr: {}".format( + ex + )) + self._last_error = str(ex) self.log.debug("End of reset_timer_and_mgr") self._reset_timer() @@ -561,12 +561,11 @@ class MPMServer(RPCServer): if component_id in self.periph_manager.updateable_components: # Check if that updating that component means the PM should be reset reset_now = (reset_now or - self.periph_manager.updateable_components[component_id]['reset']) and \ - not metadata.get('reset', "").lower() == "false" + self.periph_manager.updateable_components[component_id]['reset']) and \ + not metadata.get('reset', "").lower() == "false" else: self.log.debug("ID {} not in updateable components ({})".format( component_id, self.periph_manager.updateable_components)) - try: self.log.trace("Reset after updating component? {}".format(reset_now)) if reset_now: |