Skip to content

Commit

Permalink
Read pexpect buffers befor stopping
Browse files Browse the repository at this point in the history
pexpect.wait blocks forever if there is still output to be read when
it is called. try reading the buffers before calling wait to avoid the issue.
  • Loading branch information
guillempages committed Aug 5, 2020
1 parent ab24980 commit 16e15db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pygatt/backends/gatttool/gatttool.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,13 @@ def kill(self):
# $ sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcitool`
try:
self._scan.kill(signal.SIGINT)
self._scan.wait()
while True:
try:
self._scan.read_nonblocking()
except Exception:
break
if self._scan.isalive():
self._scan.wait()
except OSError:
log.error("Unable to gracefully stop the scan - "
"BLE adapter may need to be reset.")
Expand Down

0 comments on commit 16e15db

Please sign in to comment.