Browse code

* s3cmd: Set 10s socket timeout for read()/write().

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@461 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2010/12/23 23:01:32
Showing 4 changed files
... ...
@@ -1,5 +1,6 @@
1 1
 2010-12-24  Michal Ludvig  <mludvig@logix.net.nz>
2 2
 
3
+	* s3cmd: Set 10s socket timeout for read()/write().
3 4
 	* s3cmd: Added --(no-)check-md5 for [sync].
4 5
 	* run-tests.py, testsuite.tar.gz: Added testsuite for
5 6
 	  the above.
... ...
@@ -1,6 +1,7 @@
1 1
 s3cmd 1.0.0
2 2
 ===========
3 3
 * [sync] now supports --no-check-md5
4
+* Network connections now have 10s timeout
4 5
 
5 6
 s3cmd 1.0.0-rc2 -  2010-12-09
6 7
 ===============
... ...
@@ -74,7 +74,8 @@ class Config(object):
74 74
 	urlencoding_mode = "normal"
75 75
 	log_target_prefix = ""
76 76
 	reduced_redundancy = False
77
-        follow_symlinks=False
77
+	follow_symlinks = False
78
+	socket_timeout = 10
78 79
 
79 80
 	## Creating a singleton
80 81
 	def __new__(self, configfile = None):
... ...
@@ -22,6 +22,7 @@ import codecs
22 22
 import locale
23 23
 import subprocess
24 24
 import htmlentitydefs
25
+import socket
25 26
 
26 27
 from copy import copy
27 28
 from optparse import OptionParser, Option, OptionValueError, IndentedHelpFormatter
... ...
@@ -1906,9 +1907,12 @@ def main():
1906 1906
 	cfg.include.extend(patterns_list)
1907 1907
 	cfg.debug_include.update(patterns_textual)
1908 1908
 
1909
-        ## Process --follow-symlinks
1909
+	## Process --follow-symlinks
1910 1910
 	cfg.update_option("follow_symlinks", options.follow_symlinks)
1911 1911
 
1912
+	## Set socket read()/write() timeout
1913
+	socket.setdefaulttimeout(cfg.socket_timeout)
1914
+
1912 1915
 	if cfg.encrypt and cfg.gpg_passphrase == "":
1913 1916
 		error(u"Encryption requested but no passphrase set in config file.")
1914 1917
 		error(u"Please re-run 's3cmd --configure' and supply it.")