diff options
author | Devaev Maxim <[email protected]> | 2018-06-28 07:27:04 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-06-28 07:27:04 +0300 |
commit | d9c0e62cec7e762c9a92a8a09fa9930d2ff5ac28 (patch) | |
tree | e4c0d42bfbac25cf59b8d2999819e1fb7026fa08 | |
parent | 5925957b9663c02ac4c38e1f77d199d1552f55e7 (diff) |
fixed gpio context manager
-rw-r--r-- | kvmd/kvmd/gpio.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kvmd/kvmd/gpio.py b/kvmd/kvmd/gpio.py index 673ac373..a5197e75 100644 --- a/kvmd/kvmd/gpio.py +++ b/kvmd/kvmd/gpio.py @@ -14,9 +14,11 @@ _logger = logging.getLogger(__name__) def bcm() -> Generator[None, None, None]: GPIO.setmode(GPIO.BCM) _logger.info("Configured GPIO mode as BCM") - yield - GPIO.cleanup() - _logger.info("GPIO cleaned") + try: + yield + finally: + GPIO.cleanup() + _logger.info("GPIO cleaned") def set_output_zeroed(pin: int) -> int: |