summaryrefslogtreecommitdiff
path: root/mpv.py
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2020-07-19 22:34:24 +0200
committerjaseg <code@jaseg.net>2020-07-19 22:34:24 +0200
commit1f2b0058b390ec6b0513461a3e7b33a519ad81f8 (patch)
tree85dea082adff59b6962ac8aa4644d2790d649ae3 /mpv.py
parente85342a147d616647d08a88df2a2186a27610490 (diff)
downloadpython-mpv-1f2b0058b390ec6b0513461a3e7b33a519ad81f8.tar.gz
python-mpv-1f2b0058b390ec6b0513461a3e7b33a519ad81f8.tar.bz2
python-mpv-1f2b0058b390ec6b0513461a3e7b33a519ad81f8.zip
mpv.py: terminate: Raise warning when called from event thread.
Diffstat (limited to 'mpv.py')
-rw-r--r--mpv.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/mpv.py b/mpv.py
index 65719d7..e94dad0 100644
--- a/mpv.py
+++ b/mpv.py
@@ -1009,13 +1009,16 @@ class MPV(object):
def terminate(self):
"""Properly terminates this player instance. Preferably use this instead of relying on python's garbage
collector to cause this to be called from the object's destructor.
+
+ This method will detach the main libmpv handle and wait for mpv to shut down and the event thread to finish.
"""
self.handle, handle = None, self.handle
if threading.current_thread() is self._event_thread:
- # Handle special case to allow event handle to be detached.
- # This is necessary since otherwise the event thread would deadlock itself.
- grim_reaper = threading.Thread(target=lambda: _mpv_terminate_destroy(handle))
- grim_reaper.start()
+ raise UserWarning('terminate() should not be called from event thread (e.g. from a callback function). If '
+ 'you want to terminate mpv from here, please call quit() instead, then sync the main thread '
+ 'against the event thread using e.g. wait_for_shutdown(), then terminate() from the main thread. '
+ 'This call has been transformed into a call to quit().')
+ self.quit()
else:
_mpv_terminate_destroy(handle)
if self._event_thread: