def __exit__(self, exc_type, exc_value, traceback): for channel in self._inputs_by_channel: GPIO.remove_event_detect(channel)