code: def scan(self, wait=None):
          min_scan = self.adapter.get_config('minimum_scan_time', 0.0)
          probe_required = self.adapter.get_config('probe_required', False)
          wait_time = None
          elapsed = monotonic() - self._start_time
          if elapsed < min_scan:
              wait_time = min_scan - elapsed
          if probe_required:
              self._loop.run_coroutine(self.adapter.probe())
              wait_time = min_scan
          if wait is not None:
              wait_time = wait
          if wait_time is not None:
              sleep(wait_time)
          to_remove = set()
          now = monotonic()
          with self._scan_lock:
              for name, value in self._scanned_devices.items():
                  if value['expiration_time'] < now:
                      to_remove.add(name)
              for name in to_remove:
                  del self._scanned_devices[name]
              devices = sorted(self._scanned_devices.values(), key=lambda x: x['uuid'])
          return devices