[Pkg-mpd-commits] [python-mpd] 55/262: mpd.py: adding fileno() to export socket FD
Simon McVittie
smcv at debian.org
Sun May 22 18:16:24 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 ffd41bf4163f6d83e57b857afc2a1cb3276081a5
Author: J. Alexander Treuman <jat at spatialrift.net>
Date: Thu Jul 15 13:52:40 2010 -0400
mpd.py: adding fileno() to export socket FD
This allows access to the socket FD for polling if it can be written
to/read from. This is useful with, for example, the idle command. Simply
call send_idle(), poll the socket FD with select/poll/etc to check if it's
ready for reading, and if it is, call fetch_idle() to see what changed.
Note that select et al. call fileno() on any objects you pass to them, so
you can simply pass the MPDClient instance itself to these functions
instead of the FD returned by fileno().
---
mpd.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mpd.py b/mpd.py
index cb16701..7ff17b7 100644
--- a/mpd.py
+++ b/mpd.py
@@ -389,6 +389,11 @@ class MPDClient(object):
self._sock.close()
self._reset()
+ def fileno(self):
+ if not self._sock:
+ raise ConnectionError("Not connected")
+ return self._sock.fileno()
+
def command_list_ok_begin(self):
if self._command_list is not None:
raise CommandListError("Already in command list")
--
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