Skip to content

Commit 11d0f03

Browse files
authored
Merge pull request #307 from Azure/dev
Dev to Master
2 parents c9655db + 405f78a commit 11d0f03

File tree

616 files changed

+39891
-91426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

616 files changed

+39891
-91426
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
> See [BreakingChanges](BreakingChanges.md) for a detailed list of API breaks.
44
5+
## Version 0.34.3:
6+
- All: Made the socket timeout configurable. Increased the default socket timeout to 20 seconds.
7+
- All: Fixed a bug where SAS tokens were being duplicated on retries
8+
59
## Version 0.34.2:
610

711
### All:

azure/storage/_auth.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ def __init__(self, sas_token):
113113
self.sas_token = sas_token
114114

115115
def sign_request(self, request):
116+
# if 'sig=' is present, then the request has already been signed
117+
# as is the case when performing retries
118+
if 'sig=' in request.path:
119+
return
116120
if '?' in request.path:
117121
request.path += '&'
118122
else:

azure/storage/_connection.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
}
4848

4949
class _ServiceParameters(object):
50-
def __init__(self, service, account_name=None, account_key=None, sas_token=None,
51-
is_emulated=False, protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE,
50+
def __init__(self, service, account_name=None, account_key=None, sas_token=None,
51+
is_emulated=False, protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE,
5252
custom_domain=None):
5353

5454
self.account_name = account_name
@@ -83,36 +83,37 @@ def __init__(self, service, account_name=None, account_key=None, sas_token=None,
8383
self.protocol = self.protocol if parsed_url.scheme is '' else parsed_url.scheme
8484
else:
8585
if not self.account_name:
86-
raise ValueError(_ERROR_STORAGE_MISSING_INFO)
86+
raise ValueError(_ERROR_STORAGE_MISSING_INFO)
8787
self.primary_endpoint = '{}.{}.{}'.format(self.account_name, service, endpoint_suffix)
88-
88+
8989
# Setup the secondary endpoint
9090
if self.account_name:
9191
self.secondary_endpoint = '{}-secondary.{}.{}'.format(self.account_name, service, endpoint_suffix)
9292
else:
9393
self.secondary_endpoint = None
9494

9595
@staticmethod
96-
def get_service_parameters(service, account_name=None, account_key=None, sas_token=None, is_emulated=None,
97-
protocol=None, endpoint_suffix=None, custom_domain=None, request_session=None,
98-
connection_string=None):
96+
def get_service_parameters(service, account_name=None, account_key=None, sas_token=None, is_emulated=None,
97+
protocol=None, endpoint_suffix=None, custom_domain=None, request_session=None,
98+
connection_string=None, socket_timeout=None):
9999
if connection_string:
100100
params = _ServiceParameters._from_connection_string(connection_string, service)
101101
elif is_emulated:
102102
params = _ServiceParameters(service, is_emulated=True)
103103
elif account_name:
104104
params = _ServiceParameters(service,
105-
account_name=account_name,
106-
account_key=account_key,
107-
sas_token=sas_token,
108-
is_emulated=is_emulated,
109-
protocol=protocol,
105+
account_name=account_name,
106+
account_key=account_key,
107+
sas_token=sas_token,
108+
is_emulated=is_emulated,
109+
protocol=protocol,
110110
endpoint_suffix=endpoint_suffix,
111111
custom_domain=custom_domain)
112112
else:
113113
raise ValueError(_ERROR_STORAGE_MISSING_INFO)
114114

115115
params.request_session = request_session
116+
params.socket_timeout = socket_timeout
116117
return params
117118

118119
@staticmethod
@@ -136,10 +137,10 @@ def _from_connection_string(connection_string, service):
136137
endpoint = config.get(_CONNECTION_ENDPONTS[service])
137138

138139
return _ServiceParameters(service,
139-
account_name=account_name,
140-
account_key=account_key,
141-
sas_token=sas_token,
142-
is_emulated=is_emulated,
143-
protocol=protocol,
140+
account_name=account_name,
141+
account_key=account_key,
142+
sas_token=sas_token,
143+
is_emulated=is_emulated,
144+
protocol=protocol,
144145
endpoint_suffix=endpoint_suffix,
145146
custom_domain=endpoint)

azure/storage/_constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import platform
1616

1717
__author__ = 'Microsoft Corp. <[email protected]>'
18-
__version__ = '0.34.2'
18+
__version__ = '0.34.3'
1919

2020
# x-ms-version for storage service.
2121
X_MS_VERSION = '2016-05-31'
@@ -36,8 +36,8 @@
3636
DEV_ACCOUNT_NAME = 'devstoreaccount1'
3737
DEV_ACCOUNT_KEY = 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=='
3838

39-
# Socket timeout in seconds is 11
40-
SOCKET_TIMEOUT = 11
39+
# Socket timeout in seconds
40+
DEFAULT_SOCKET_TIMEOUT = 20
4141

4242
#Encryption constants
4343
_ENCRYPTION_PROTOCOL_V1 = '1.0'

azure/storage/blob/appendblobservice.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class AppendBlobService(BaseBlobService):
7474

7575
def __init__(self, account_name=None, account_key=None, sas_token=None,
7676
is_emulated=False, protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE,
77-
custom_domain=None, request_session=None, connection_string=None):
77+
custom_domain=None, request_session=None, connection_string=None, socket_timeout=None):
7878
'''
7979
:param str account_name:
8080
The storage account name. This is used to authenticate requests
@@ -110,11 +110,14 @@ def __init__(self, account_name=None, account_key=None, sas_token=None,
110110
request session. See
111111
http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/
112112
for the connection string format.
113+
:param int socket_timeout:
114+
If specified, this will override the default socket timeout. The timeout specified is in seconds.
115+
See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value.
113116
'''
114117
self.blob_type = _BlobTypes.AppendBlob
115118
super(AppendBlobService, self).__init__(
116119
account_name, account_key, sas_token, is_emulated, protocol, endpoint_suffix,
117-
custom_domain, request_session, connection_string)
120+
custom_domain, request_session, connection_string, socket_timeout)
118121

119122
def create_blob(self, container_name, blob_name, content_settings=None,
120123
metadata=None, lease_id=None,

azure/storage/blob/baseblobservice.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class BaseBlobService(StorageClient):
150150

151151
def __init__(self, account_name=None, account_key=None, sas_token=None,
152152
is_emulated=False, protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE,
153-
custom_domain=None, request_session=None, connection_string=None):
153+
custom_domain=None, request_session=None, connection_string=None, socket_timeout=None):
154154
'''
155155
:param str account_name:
156156
The storage account name. This is used to authenticate requests
@@ -186,6 +186,9 @@ def __init__(self, account_name=None, account_key=None, sas_token=None,
186186
request session. See
187187
http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/
188188
for the connection string format
189+
:param int socket_timeout:
190+
If specified, this will override the default socket timeout. The timeout specified is in seconds.
191+
See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value.
189192
'''
190193
service_params = _ServiceParameters.get_service_parameters(
191194
'blob',
@@ -197,7 +200,8 @@ def __init__(self, account_name=None, account_key=None, sas_token=None,
197200
endpoint_suffix=endpoint_suffix,
198201
custom_domain=custom_domain,
199202
request_session=request_session,
200-
connection_string=connection_string)
203+
connection_string=connection_string,
204+
socket_timeout=socket_timeout)
201205

202206
super(BaseBlobService, self).__init__(service_params)
203207

azure/storage/blob/blockblobservice.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class BlockBlobService(BaseBlobService):
104104

105105
def __init__(self, account_name=None, account_key=None, sas_token=None,
106106
is_emulated=False, protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE,
107-
custom_domain=None, request_session=None, connection_string=None):
107+
custom_domain=None, request_session=None, connection_string=None, socket_timeout=None):
108108
'''
109109
:param str account_name:
110110
The storage account name. This is used to authenticate requests
@@ -140,11 +140,14 @@ def __init__(self, account_name=None, account_key=None, sas_token=None,
140140
request session. See
141141
http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/
142142
for the connection string format.
143+
:param int socket_timeout:
144+
If specified, this will override the default socket timeout. The timeout specified is in seconds.
145+
See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value.
143146
'''
144147
self.blob_type = _BlobTypes.BlockBlob
145148
super(BlockBlobService, self).__init__(
146149
account_name, account_key, sas_token, is_emulated, protocol, endpoint_suffix,
147-
custom_domain, request_session, connection_string)
150+
custom_domain, request_session, connection_string, socket_timeout)
148151

149152
def put_block(self, container_name, blob_name, block, block_id,
150153
validate_content=False, lease_id=None, timeout=None):

azure/storage/blob/pageblobservice.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class PageBlobService(BaseBlobService):
8888

8989
def __init__(self, account_name=None, account_key=None, sas_token=None,
9090
is_emulated=False, protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE,
91-
custom_domain=None, request_session=None, connection_string=None):
91+
custom_domain=None, request_session=None, connection_string=None, socket_timeout=None):
9292
'''
9393
:param str account_name:
9494
The storage account name. This is used to authenticate requests
@@ -124,11 +124,14 @@ def __init__(self, account_name=None, account_key=None, sas_token=None,
124124
request session. See
125125
http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/
126126
for the connection string format.
127+
:param int socket_timeout:
128+
If specified, this will override the default socket timeout. The timeout specified is in seconds.
129+
See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value.
127130
'''
128131
self.blob_type = _BlobTypes.PageBlob
129132
super(PageBlobService, self).__init__(
130133
account_name, account_key, sas_token, is_emulated, protocol, endpoint_suffix,
131-
custom_domain, request_session, connection_string)
134+
custom_domain, request_session, connection_string, socket_timeout)
132135

133136
def create_blob(
134137
self, container_name, blob_name, content_length, content_settings=None,

azure/storage/file/fileservice.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class FileService(StorageClient):
124124

125125
def __init__(self, account_name=None, account_key=None, sas_token=None,
126126
protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE,
127-
request_session=None, connection_string=None):
127+
request_session=None, connection_string=None, socket_timeout=None):
128128
'''
129129
:param str account_name:
130130
The storage account name. This is used to authenticate requests
@@ -149,6 +149,9 @@ def __init__(self, account_name=None, account_key=None, sas_token=None,
149149
request session. See
150150
http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/
151151
for the connection string format.
152+
:param int socket_timeout:
153+
If specified, this will override the default socket timeout. The timeout specified is in seconds.
154+
See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value.
152155
'''
153156
service_params = _ServiceParameters.get_service_parameters(
154157
'file',
@@ -158,7 +161,8 @@ def __init__(self, account_name=None, account_key=None, sas_token=None,
158161
protocol=protocol,
159162
endpoint_suffix=endpoint_suffix,
160163
request_session=request_session,
161-
connection_string=connection_string)
164+
connection_string=connection_string,
165+
socket_timeout=socket_timeout)
162166

163167
super(FileService, self).__init__(service_params)
164168

azure/storage/queue/queueservice.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class QueueService(StorageClient):
132132

133133
def __init__(self, account_name=None, account_key=None, sas_token=None,
134134
is_emulated=False, protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE,
135-
request_session=None, connection_string=None):
135+
request_session=None, connection_string=None, socket_timeout=None):
136136
'''
137137
:param str account_name:
138138
The storage account name. This is used to authenticate requests
@@ -161,6 +161,9 @@ def __init__(self, account_name=None, account_key=None, sas_token=None,
161161
request session. See
162162
http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/
163163
for the connection string format.
164+
:param int socket_timeout:
165+
If specified, this will override the default socket timeout. The timeout specified is in seconds.
166+
See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value.
164167
'''
165168
service_params = _ServiceParameters.get_service_parameters(
166169
'queue',
@@ -171,7 +174,8 @@ def __init__(self, account_name=None, account_key=None, sas_token=None,
171174
protocol=protocol,
172175
endpoint_suffix=endpoint_suffix,
173176
request_session=request_session,
174-
connection_string=connection_string)
177+
connection_string=connection_string,
178+
socket_timeout=socket_timeout)
175179

176180
super(QueueService, self).__init__(service_params)
177181

0 commit comments

Comments
 (0)