diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2018-08-14 10:05:56 -0700 |
---|---|---|
committer | Brent Stapleton <bstapleton@g.hmc.edu> | 2018-08-27 18:14:23 -0700 |
commit | 191e250827a54d15abc9f7a5586318a29728d1b0 (patch) | |
tree | c677343908e19b4c6c333687db56859f988f8fe9 /mpm/python | |
parent | 6849514a05259dc6282d41325c6ed3b3ac12d0cb (diff) | |
download | uhd-191e250827a54d15abc9f7a5586318a29728d1b0.tar.gz uhd-191e250827a54d15abc9f7a5586318a29728d1b0.tar.bz2 uhd-191e250827a54d15abc9f7a5586318a29728d1b0.zip |
mpm: reset the RPC server upon reload
When reloading the Periph Manager (as when we run the image loader),
we need to run the RPCServer `__init__` function in order to reset the
cache of RPC methods. Otherwise, that cache keeps stale references to
old functions (and prevents garbage collection).
It may be possible to reset the method cache some other way, but the
`_methods` attribute of RPCServer is Cython, and doesn't seem to be
accessible in our Python code.
Diffstat (limited to 'mpm/python')
-rw-r--r-- | mpm/python/usrp_mpm/rpc_server.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py index 29ad3daa8..35202efa9 100644 --- a/mpm/python/usrp_mpm/rpc_server.py +++ b/mpm/python/usrp_mpm/rpc_server.py @@ -457,6 +457,16 @@ class MPMServer(RPCServer): self.periph_manager = None self.periph_manager = self._mgr_generator() self._init_rpc_calls(self.periph_manager) + # RPCServer caches RPC methods, but that cache is not accessible here + # (because Cython). Re-running `RPCServer.__init__` clears that cache, + # and allows us to register new RPC methods (which we need to do because + # we're resetting the PeriphManager). + # A note on maintenance: This has been deemed safe through inspection of + # the RPCServer source code. However, this is not typical Python, and + # changes in future versions of RPCServer may cause issues. + super(MPMServer, self).__init__( + pack_params={'use_bin_type': True}, + ) def update_component(self, token, file_metadata_l, data_l): """" |