diff --git a/sendspin/hook_volume.py b/sendspin/hook_volume.py index d7cda98..c042a6e 100644 --- a/sendspin/hook_volume.py +++ b/sendspin/hook_volume.py @@ -50,7 +50,12 @@ async def set_state(self, volume: int, *, muted: bool) -> None: stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, ) - stdout, stderr = await proc.communicate() + try: + stdout, stderr = await asyncio.wait_for(proc.communicate(), timeout=10) + except TimeoutError: + proc.kill() + await proc.wait() + raise RuntimeError(f"Volume hook timed out: {' '.join(self._argv)}") from None if proc.returncode != 0: raise RuntimeError( "Volume hook failed "