summaryrefslogtreecommitdiff
path: root/mpv.py
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2020-07-19 22:33:56 +0200
committerjaseg <code@jaseg.net>2020-07-19 22:33:56 +0200
commite85342a147d616647d08a88df2a2186a27610490 (patch)
tree64f7b413c43b27c5a12e09d5dceee885398acf78 /mpv.py
parentd6840f800e6c0ac6fe890471094fee3b0177c2ab (diff)
downloadpython-mpv-e85342a147d616647d08a88df2a2186a27610490.tar.gz
python-mpv-e85342a147d616647d08a88df2a2186a27610490.tar.bz2
python-mpv-e85342a147d616647d08a88df2a2186a27610490.zip
mpv.py: add wait_for_shutdown
Diffstat (limited to 'mpv.py')
-rw-r--r--mpv.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/mpv.py b/mpv.py
index f0cd22a..65719d7 100644
--- a/mpv.py
+++ b/mpv.py
@@ -924,6 +924,17 @@ class MPV(object):
with self.prepare_and_wait_for_property(name, cond, level_sensitive):
pass
+ def wait_for_shutdown(self):
+ '''Wait for core to shutdown (e.g. through quit() or terminate()).'''
+ sema = threading.Semaphore(value=0)
+
+ @self.event_callback('shutdown')
+ def shutdown_handler(event):
+ sema.release()
+
+ sema.acquire()
+ shutdown_handler.unregister_mpv_events()
+
@contextmanager
def prepare_and_wait_for_property(self, name, cond=lambda val: val, level_sensitive=True):
"""Context manager that waits until ``cond`` evaluates to a truthy value on the named property. See