From 48d5d72fd76bbf615ea88fa9d5177471ed3d15a9 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Mon, 27 Nov 2017 18:19:45 -0800 Subject: mpm: adding destructor for UIO UIO object now has an explicit destructor to properly tear down. --- mpm/python/usrp_mpm/uio.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'mpm') diff --git a/mpm/python/usrp_mpm/uio.py b/mpm/python/usrp_mpm/uio.py index 2ea76233f..40991f1eb 100644 --- a/mpm/python/usrp_mpm/uio.py +++ b/mpm/python/usrp_mpm/uio.py @@ -136,6 +136,17 @@ class UIO(object): offset=offset, ) + def __del__(self): + """ + Destructor needs to close the uio-mapped memory + """ + try: + self._mm.close() + os.close(self._fd) + except: + self.log.warning("Failed to properly destruct UIO object.") + pass + def peek32(self, addr): """ Returns the 32-bit value starting at address addr as an integer -- cgit v1.2.3