diff --git a/anki/mpv.py b/anki/mpv.py index 5807d2dbe..93137386f 100644 --- a/anki/mpv.py +++ b/anki/mpv.py @@ -344,7 +344,7 @@ class MPVBase: except Empty: return None - def _send_request(self, message, timeout=None): + def _send_request(self, message, timeout=None, _retry=1): """Send a command to the mpv process and collect the result. """ self.ensure_running() @@ -353,6 +353,13 @@ class MPVBase: return self._get_response(timeout) except MPVCommandError as e: raise MPVCommandError("%r: %s" % (message["command"], e)) + except MPVTimeoutError as e: + if _retry: + print("mpv timed out, restarting") + self._stop_process() + return self._send_request(message, timeout, _retry-1) + else: + raise # # Public API