[Pkg-mpd-commits] [python-mpd] 233/262: Improved the idle.py example.
Simon McVittie
smcv at debian.org
Sun May 22 18:16:51 UTC 2016
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch upstream
in repository python-mpd.
commit 8d81ea9f57836ec701ac707da49e90c399c82c2f
Author: Michael Helmling <michaelhelmling at posteo.de>
Date: Mon Feb 3 09:45:57 2014 +0100
Improved the idle.py example.
It now becomes clear what to do with the output of select(), and how
to call that function properly.
---
examples/idle.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/examples/idle.py b/examples/idle.py
index 3bf21d1..fadf07d 100644
--- a/examples/idle.py
+++ b/examples/idle.py
@@ -4,10 +4,15 @@
#
#http://www.musicpd.org/doc/protocol/ch02.html#id525963
#Example
+from select import select
client.send_idle()
-select([client], [], [])
-changed = client.fetch_idle()
+# do this periodically, e.g. in event loop
+canRead = select([client], [], [], 0)[0]
+if canRead:
+ changes = client.fetch_idle()
+ print(changes) # handle changes
+ client.send_idle() # continue idling
#You can also poll the socket FD (returned by client.fileno(), which is called by default by select, poll, etc.) using other tools too.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mpd/python-mpd.git
More information about the Pkg-mpd-commits
mailing list