From 79cbdb4fbbd99536501051a3abf4fd3d0121d241 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 19 Dec 2012 23:43:48 +0100 Subject: [PATCH] mpd: Add MPD_SERVER_CONNECTION_TIMEOUT setting --- docs/changes.rst | 4 ++++ mopidy/frontends/mpd/actor.py | 3 ++- mopidy/settings.py | 10 ++++++++++ mopidy/utils/network.py | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index b5217200..e72abc02 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -15,6 +15,10 @@ v0.11.0 (in development) **MPD frontend** +- Add :attr:`mopidy.settings.MPD_SERVER_CONNECTION_TIMEOUT` setting which + controls how long an MPD client can stay inactive before the connection is + closed by the server. + - Add support for the ``findadd`` command. - Updated to match the MPD 0.17 protocol (Fixes: :issue:`228`): diff --git a/mopidy/frontends/mpd/actor.py b/mopidy/frontends/mpd/actor.py index d3c718c4..11e07aa7 100644 --- a/mopidy/frontends/mpd/actor.py +++ b/mopidy/frontends/mpd/actor.py @@ -23,7 +23,8 @@ class MpdFrontend(pykka.ThreadingActor, CoreListener): network.Server( hostname, port, protocol=session.MpdSession, protocol_kwargs={'core': core}, - max_connections=settings.MPD_SERVER_MAX_CONNECTIONS) + max_connections=settings.MPD_SERVER_MAX_CONNECTIONS, + timeout=settings.MPD_SERVER_CONNECTION_TIMEOUT) except IOError as error: logger.error( 'MPD server startup failed: %s', diff --git a/mopidy/settings.py b/mopidy/settings.py index 0a272035..c2081e27 100644 --- a/mopidy/settings.py +++ b/mopidy/settings.py @@ -174,6 +174,16 @@ MIXER = 'autoaudiomixer' #: MIXER_TRACK = None MIXER_TRACK = None +#: Number of seconds an MPD client can stay inactive before the connection is +#: closed by the server. +#: +#: Used by :mod:`mopidy.frontends.mpd`. +#: +#: Default:: +#: +#: MPD_SERVER_CONNECTION_TIMEOUT = 60 +MPD_SERVER_CONNECTION_TIMEOUT = 60 + #: Which address Mopidy's MPD server should bind to. #: #: Used by :mod:`mopidy.frontends.mpd`. diff --git a/mopidy/utils/network.py b/mopidy/utils/network.py index 604350d1..1ffb12d6 100644 --- a/mopidy/utils/network.py +++ b/mopidy/utils/network.py @@ -291,7 +291,7 @@ class Connection(object): return True def timeout_callback(self): - self.stop('Client timeout out after %s seconds' % self.timeout) + self.stop('Client inactive for %ds; closing connection' % self.timeout) return False