mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
restart mpv if it stops responding
https://anki.tenderapp.com/discussions/ankidesktop/31433-error
This commit is contained in:
parent
15721d840f
commit
727570418c
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue