Commit ac7ee9a1 authored by gotcha's avatar gotcha

with -t option, timeout is set right away

git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@109993 62d5b8a3-27da-0310-9561-8e5933582275
parent 54a98bc8
...@@ -32,6 +32,7 @@ import pkg_resources ...@@ -32,6 +32,7 @@ import pkg_resources
import re import re
import shutil import shutil
import sys import sys
import socket
import tempfile import tempfile
import UserDict import UserDict
import zc.buildout import zc.buildout
...@@ -125,6 +126,11 @@ _buildout_default_options = _annotate_section({ ...@@ -125,6 +126,11 @@ _buildout_default_options = _annotate_section({
}, 'DEFAULT_VALUE') }, 'DEFAULT_VALUE')
def _setup_socket_timeout(timeout):
socket.setdefaulttimeout(timeout)
return 'Setting socket time out to %d seconds.' % timeout
class Buildout(UserDict.DictMixin): class Buildout(UserDict.DictMixin):
def __init__(self, config_file, cloptions, def __init__(self, config_file, cloptions,
...@@ -756,9 +762,10 @@ class Buildout(UserDict.DictMixin): ...@@ -756,9 +762,10 @@ class Buildout(UserDict.DictMixin):
if timeout <> '': if timeout <> '':
try: try:
timeout = int(timeout) timeout = int(timeout)
import socket socket_timeout = socket.getdefaulttimeout()
self._logger.info('Setting socket time out to %d seconds.', timeout) if socket_timeout <> timeout:
socket.setdefaulttimeout(timeout) info_msg = _setup_socket_timeout(timeout)
self._logger.info(info_msg)
except ValueError: except ValueError:
self._logger.warning("Default socket timeout is used !\n" self._logger.warning("Default socket timeout is used !\n"
"Value in configuration is not numeric: [%s].\n", "Value in configuration is not numeric: [%s].\n",
...@@ -1637,6 +1644,9 @@ def main(args=None): ...@@ -1637,6 +1644,9 @@ def main(args=None):
_error("No timeout value specified for option", orig_op) _error("No timeout value specified for option", orig_op)
except ValueError: except ValueError:
_error("Timeout value must be numeric", orig_op) _error("Timeout value must be numeric", orig_op)
info_msg = _setup_socket_timeout(timeout)
print info_msg
elif op: elif op:
if orig_op == '--help': if orig_op == '--help':
_help() _help()
......
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