summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuan Zhou <yuan.zhou@intel.com>2013-09-04 15:20:08 +0800
committerYuan Zhou <yuan.zhou@intel.com>2013-09-29 21:37:07 +0800
commitdbdbaa0321a709d67464ce777139af910f8b57af (patch)
treeb67c3d1a9e774af25d6d284b965376b733dc6140
parent0278998398cbe0caeb5237b30e316c0a59669c87 (diff)
downloadpython-swiftclient-dbdbaa0321a709d67464ce777139af910f8b57af.tar.gz
Skip sniffing and reseting if retry is disabled
Bypass sniffing entirely if retries has been disabled. Fix bug #1216981 Change-Id: I593bdc56ca139af5a7f2ca2783ef2de2a96c94fb Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
-rw-r--r--swiftclient/client.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index a95ce70..6a0cca8 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -1213,18 +1213,17 @@ class Connection(object):
'ability to reset contents for reupload.'
% (container, obj))
- if isinstance(contents, str):
- # if its a str then you can retry as much as you want
+ if isinstance(contents, str) or not contents:
+ # if its a str or None then you can retry as much as you want
reset_func = None
else:
reset_func = _default_reset
- tell = getattr(contents, 'tell', None)
- seek = getattr(contents, 'seek', None)
- if tell and seek:
- orig_pos = tell()
- reset_func = lambda *a, **k: seek(orig_pos)
- elif not contents:
- reset_func = lambda *a, **k: None
+ if self.retries > 0:
+ tell = getattr(contents, 'tell', None)
+ seek = getattr(contents, 'seek', None)
+ if tell and seek:
+ orig_pos = tell()
+ reset_func = lambda *a, **k: seek(orig_pos)
return self._retry(reset_func, put_object, container, obj, contents,
content_length=content_length, etag=etag,