Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.buildout
Commits
4c912de9
Commit
4c912de9
authored
Mar 16, 2010
by
Godefroid Chapelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set socket timeout just after we parse each *.cfg file
parent
325467b4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
34 deletions
+25
-34
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+22
-24
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+3
-10
No files found.
src/zc/buildout/buildout.py
View file @
4c912de9
...
@@ -125,10 +125,16 @@ _buildout_default_options = _annotate_section({
...
@@ -125,10 +125,16 @@ _buildout_default_options = _annotate_section({
'socket-timeout'
:
''
,
'socket-timeout'
:
''
,
},
'DEFAULT_VALUE'
)
},
'DEFAULT_VALUE'
)
DEFAULT_SOCKET_TIMEOUT
=
socket
.
getdefaulttimeout
()
def
_setup_socket_timeout
(
timeout
):
def
_setup_socket_timeout
(
timeout_string
):
try
:
timeout
=
int
(
timeout_string
)
except
ValueError
:
_error
(
"Timeout value must be numeric [%s]."
%
timeout_string
)
current_timeout
=
socket
.
getdefaulttimeout
()
if
current_timeout
<>
timeout
:
socket
.
setdefaulttimeout
(
timeout
)
socket
.
setdefaulttimeout
(
timeout
)
return
'Setting socket time out to %d seconds.'
%
timeout
class
Buildout
(
UserDict
.
DictMixin
):
class
Buildout
(
UserDict
.
DictMixin
):
...
@@ -252,7 +258,7 @@ class Buildout(UserDict.DictMixin):
...
@@ -252,7 +258,7 @@ class Buildout(UserDict.DictMixin):
options
[
'installed'
])
options
[
'installed'
])
self
.
_setup_logging
()
self
.
_setup_logging
()
self
.
_
setup
_socket_timeout
()
self
.
_
display
_socket_timeout
()
offline
=
options
.
get
(
'offline'
,
'false'
)
offline
=
options
.
get
(
'offline'
,
'false'
)
if
offline
not
in
(
'true'
,
'false'
):
if
offline
not
in
(
'true'
,
'false'
):
...
@@ -757,19 +763,11 @@ class Buildout(UserDict.DictMixin):
...
@@ -757,19 +763,11 @@ class Buildout(UserDict.DictMixin):
def
_error
(
self
,
message
,
*
args
):
def
_error
(
self
,
message
,
*
args
):
raise
zc
.
buildout
.
UserError
(
message
%
args
)
raise
zc
.
buildout
.
UserError
(
message
%
args
)
def
_setup_socket_timeout
(
self
):
def
_display_socket_timeout
(
self
):
timeout
=
self
[
'buildout'
][
'socket-timeout'
]
current_timeout
=
socket
.
getdefaulttimeout
()
if
timeout
<>
''
:
if
current_timeout
<>
DEFAULT_SOCKET_TIMEOUT
:
try
:
info_msg
=
'Socket timeout is set to %d seconds.'
%
current_timeout
timeout
=
int
(
timeout
)
socket_timeout
=
socket
.
getdefaulttimeout
()
if
socket_timeout
<>
timeout
:
info_msg
=
_setup_socket_timeout
(
timeout
)
self
.
_logger
.
info
(
info_msg
)
self
.
_logger
.
info
(
info_msg
)
except
ValueError
:
self
.
_logger
.
warning
(
"Default socket timeout is used !
\
n
"
"Value in configuration is not numeric: [%s].
\
n
"
,
timeout
)
def
_setup_logging
(
self
):
def
_setup_logging
(
self
):
root_logger
=
logging
.
getLogger
()
root_logger
=
logging
.
getLogger
()
...
@@ -1338,13 +1336,18 @@ def _open(base, filename, seen, dl_options, override):
...
@@ -1338,13 +1336,18 @@ def _open(base, filename, seen, dl_options, override):
os
.
remove
(
path
)
os
.
remove
(
path
)
extends
=
extended_by
=
None
extends
=
extended_by
=
None
socket_timeout
=
None
for
section
in
parser
.
sections
():
for
section
in
parser
.
sections
():
options
=
dict
(
parser
.
items
(
section
))
options
=
dict
(
parser
.
items
(
section
))
if
section
==
'buildout'
:
if
section
==
'buildout'
:
extends
=
options
.
pop
(
'extends'
,
extends
)
extends
=
options
.
pop
(
'extends'
,
extends
)
extended_by
=
options
.
pop
(
'extended-by'
,
extended_by
)
extended_by
=
options
.
pop
(
'extended-by'
,
extended_by
)
socket_timeout
=
options
.
pop
(
'socket-timeout'
,
socket_timeout
)
result
[
section
]
=
options
result
[
section
]
=
options
if
socket_timeout
is
not
None
:
_setup_socket_timeout
(
socket_timeout
)
result
=
_annotate
(
result
,
filename
)
result
=
_annotate
(
result
,
filename
)
if
root_config_file
and
'buildout'
in
result
:
if
root_config_file
and
'buildout'
in
result
:
...
@@ -1638,15 +1641,10 @@ def main(args=None):
...
@@ -1638,15 +1641,10 @@ def main(args=None):
elif
op_
==
't'
:
elif
op_
==
't'
:
try
:
try
:
timeout_string
=
args
.
pop
(
0
)
timeout_string
=
args
.
pop
(
0
)
timeout
=
in
t
(
timeout_string
)
_setup_socket_timeou
t
(
timeout_string
)
options
.
append
((
'buildout'
,
'socket-timeout'
,
timeout_string
))
options
.
append
((
'buildout'
,
'socket-timeout'
,
timeout_string
))
except
IndexError
:
except
IndexError
:
_error
(
"No timeout value specified for option"
,
orig_op
)
_error
(
"No timeout value specified for option t"
,
orig_op
)
except
ValueError
:
_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
()
...
...
src/zc/buildout/buildout.txt
View file @
4c912de9
...
@@ -1512,15 +1512,14 @@ configured in the buildout section. Its value is configured in seconds.
...
@@ -1512,15 +1512,14 @@ configured in the buildout section. Its value is configured in seconds.
... """)
... """)
>>> print system(buildout),
>>> print system(buildout),
S
etting socket time ou
t to 5 seconds.
S
ocket timeout is se
t to 5 seconds.
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Installing debug.
Installing debug.
op timeout
op timeout
recipe recipes:debug
recipe recipes:debug
If the socket-timeout is not numeric, a warning is issued and the default
If socket-timeout is not numeric, an error message is issued.
timeout of the Python socket module is used.
>>> write(sample_buildout, 'buildout.cfg',
>>> write(sample_buildout, 'buildout.cfg',
... """
... """
...
@@ -1535,13 +1534,7 @@ timeout of the Python socket module is used.
...
@@ -1535,13 +1534,7 @@ timeout of the Python socket module is used.
... """)
... """)
>>> print system(buildout),
>>> print system(buildout),
Default socket timeout is used !
Error: Timeout value must be numeric [5s].
Value in configuration is not numeric: [5s].
<BLANKLINE>
Develop: '/sample-buildout/recipes'
Updating debug.
op timeout
recipe recipes:debug
Uninstall recipes
Uninstall recipes
-----------------
-----------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment