Skip to content

Commit

Permalink
improv: avoid deadlock when sigrok-cli process failed
Browse files Browse the repository at this point in the history
  • Loading branch information
flxzt committed Apr 25, 2024
1 parent 110532f commit 798afbf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions labgrid/driver/sigrokdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ def capture(self, filename, samplerate="200k"):
args = self.sigrok.command_prefix + ['test', '-e', filename]

while subprocess.call(args):
# in case the sigrok-cli call fails, this would wait forever.
# to avoid this, we also check the spawned sigrok process
if self._process.poll() is not None:
ret = self._process.returncode
if ret != 0:
stdout, stderr = self._process.communicate()
self.logger.debug("sigrok-cli call terminated prematurely with non-zero return-code")
self.logger.debug("stdout: %s", stdout)
self.logger.debug("stderr: %s", stderr)
raise ExecutionError(f"sigrok-cli call terminated prematurely with return-code '{ret}'.")
sleep(0.1)

self._running = True
Expand Down

0 comments on commit 798afbf

Please sign in to comment.