code: def wait_for_notification(self, handle: int, delegate, notification_timeout: float):
          if not self.is_connected():
              raise BluetoothBackendException('Not connected to any device.')
          attempt = 0
          delay = 10
          _LOGGER.debug("Enter write_ble (%s)", current_thread())
          while attempt <= self.retries:
              cmd = "gatttool --device={} --addr-type={} --char-write-req -a {} -n {} --adapter={} --listen".format(
                  self._mac, self.address_type, self.byte_to_handle(handle), self.bytes_to_string(self._DATA_MODE_LISTEN),
                  self.adapter)
              _LOGGER.debug("Running gatttool with a timeout of %d: %s", notification_timeout, cmd)
              with Popen(cmd,
                         shell=True,
                         stdout=PIPE,
                         stderr=PIPE,
                         preexec_fn=os.setsid) as process:
                  try:
                      result = process.communicate(timeout=notification_timeout)[0]
                      _LOGGER.debug("Finished gatttool")
                  except TimeoutExpired:
                      os.killpg(process.pid, signal.SIGINT)
                      result = process.communicate()[0]
                      _LOGGER.debug("Listening stopped forcefully after timeout.")
              result = result.decode("utf-8").strip(' \n\t')
              if "Write Request failed" in result:
                  raise BluetoothBackendException('Error writing handle to sensor: {}'.format(result))
              _LOGGER.debug("Got %s from gatttool", result)
              if "successfully" in result:
                  _LOGGER.debug("Exit write_ble with result (%s)", current_thread())
                  for element in self.extract_notification_payload(result):
                      delegate.handleNotification(handle, bytes([int(x, 16) for x in element.split()]))
                  return True
              attempt += 1
              _LOGGER.debug("Waiting for %s seconds before retrying", delay)
              if attempt < self.retries:
                  time.sleep(delay)
                  delay *= 2
          raise BluetoothBackendException("Exit write_ble, no data ({})".format(current_thread()))