From 3f041f016053b04b6d6800186a27a7c0700e475c Mon Sep 17 00:00:00 2001 From: Kaliko Jack Date: Tue, 17 Jun 2014 16:37:14 +0200 Subject: [PATCH] Document send_*/fetch_* and idle commands --- README.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.rst b/README.rst index a926514..2bd88dc 100644 --- a/README.rst +++ b/README.rst @@ -62,6 +62,25 @@ Commands may also return iterators instead of lists if `iterate` is set to for song in client.playlistinfo(): print song['file'] +Each command have a *send\_* and a *fetch\_* variant, which allows to +send a MPD command and then fetch the result later. +This is useful for the idle command:: + + >>> client.send_idle() + # do something else or use function like select() + # http://docs.python.org/howto/sockets.html#non-blocking-sockets + # ex. select([client], [], []) + >>> events = client.fetch_idle() + + # more complex use for example, with glib/gobject: + >>> def callback(source, condition): + >>> changes = client.fetch_idle() + >>> print changes + >>> return False # removes the IO watcher + + >>> client.send_idle() + >>> gobject.io_add_watch(client, gobject.IO_IN, callback) + >>> gobject.MainLoop().run() Contacting authors ------------------ -- 2.39.2