diff options
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r-- | mpm/python/usrp_mpm/mpmutils.py | 6 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/sys_utils/uio.py | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/mpm/python/usrp_mpm/mpmutils.py b/mpm/python/usrp_mpm/mpmutils.py index a0716d1da..f7e4e3be1 100644 --- a/mpm/python/usrp_mpm/mpmutils.py +++ b/mpm/python/usrp_mpm/mpmutils.py @@ -182,6 +182,8 @@ def lock_guard(lockable): lockable -- Must have a .lock() and .unlock() method """ lockable.lock() - yield - lockable.unlock() + try: + yield + finally: + lockable.unlock() diff --git a/mpm/python/usrp_mpm/sys_utils/uio.py b/mpm/python/usrp_mpm/sys_utils/uio.py index c724557e6..84e4b2b64 100644 --- a/mpm/python/usrp_mpm/sys_utils/uio.py +++ b/mpm/python/usrp_mpm/sys_utils/uio.py @@ -24,8 +24,10 @@ def open_uio(label=None, path=None, length=None, read_only=True, offset=None): Use this like you would open() for a file""" uio_obj = UIO(label, path, length, read_only, offset) uio_obj._open() - yield uio_obj - uio_obj._close() + try: + yield uio_obj + finally: + uio_obj._close() def get_all_uio_devs(): |