Commit 2bf8b65c authored by Godefroid Chapelle's avatar Godefroid Chapelle

Added buildout:socket-timout option so that socket timeout can be configured

both from command line and from config files.
parent a260a0a6
......@@ -4,6 +4,10 @@ Change History
1.4.4 (?)
=========
New feature:
- Added buildout:socket-timout option so that socket timeout can be configured
both from command line and from config files. (gotcha)
1.4.3 (2009-12-10)
==================
......
......@@ -121,6 +121,7 @@ _buildout_default_options = _annotate_section({
'executable': sys.executable,
'log-level': 'INFO',
'log-format': '',
'socket-timeout': '',
}, 'DEFAULT_VALUE')
......@@ -245,6 +246,7 @@ class Buildout(UserDict.DictMixin):
options['installed'])
self._setup_logging()
self._setup_socket_timeout()
offline = options.get('offline', 'false')
if offline not in ('true', 'false'):
......@@ -749,6 +751,19 @@ class Buildout(UserDict.DictMixin):
def _error(self, message, *args):
raise zc.buildout.UserError(message % args)
def _setup_socket_timeout(self):
timeout = self['buildout']['socket-timeout']
if timeout <> '':
try:
timeout = int(timeout)
import socket
self._logger.info('Setting socket time out to %d seconds.', timeout)
socket.setdefaulttimeout(timeout)
except ValueError:
self._logger.warning("Default socket timeout is used !\n"
"Value in configuration is not numeric: [%s].\n",
timeout)
def _setup_logging(self):
root_logger = logging.getLogger()
self._logger = logging.getLogger('zc.buildout')
......@@ -1615,16 +1630,13 @@ def main(args=None):
_error("No file name specified for option", orig_op)
elif op_ == 't':
try:
timeout = int(args.pop(0))
timeout_string = args.pop(0)
timeout = int(timeout_string)
options.append(('buildout', 'socket-timeout', timeout_string))
except IndexError:
_error("No timeout value specified for option", orig_op)
except ValueError:
_error("No timeout value must be numeric", orig_op)
import socket
print 'Setting socket time out to %d seconds' % timeout
socket.setdefaulttimeout(timeout)
_error("Timeout value must be numeric", orig_op)
elif op:
if orig_op == '--help':
_help()
......
......@@ -748,6 +748,8 @@ COMMAND_LINE_VALUE).
DEFAULT_VALUE
python= buildout
DEFAULT_VALUE
socket-timeout=
DEFAULT_VALUE
<BLANKLINE>
[data-dir]
path= foo bins
......@@ -1491,6 +1493,56 @@ set the logging level to WARNING
op3 b2 3
recipe recipes:debug
Socket timeout
--------------
The timeout of the connections to egg and configuration servers can be
configured in the buildout section. Its value is configured in seconds.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... socket-timeout = 5
... develop = recipes
... parts = debug
...
... [debug]
... recipe = recipes:debug
... op = timeout
... """)
>>> print system(buildout),
Setting socket time out to 5 seconds.
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Installing debug.
op timeout
recipe recipes:debug
If the socket-timeout is not numeric, a warning is issued and the default
timeout of the Python socket module is used.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... socket-timeout = 5s
... develop = recipes
... parts = debug
...
... [debug]
... recipe = recipes:debug
... op = timeout
... """)
>>> print system(buildout),
Default socket timeout is used !
Value in configuration is not numeric: [5s].
<BLANKLINE>
Develop: '/sample-buildout/recipes'
Updating debug.
op timeout
recipe recipes:debug
Uninstall recipes
-----------------
......@@ -2213,6 +2265,7 @@ database is shown.
parts =
parts-directory = /sample-buildout/parts
python = buildout
socket-timeout =
verbosity = 20
<BLANKLINE>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment