Azure / azure-storage-python

Microsoft Azure Storage Library for Python
https://azure-storage.readthedocs.io
MIT License
339 stars 241 forks source link

Tuple timeout setting is deprecated #644

Closed AliYmn closed 4 years ago

AliYmn commented 4 years ago

Which service(blob, file, queue) does this issue concern?

Based on creating Container.

Which version of the SDK was used? Please provide the output of pip freeze.

azure-common==1.1.16 azure-core==1.1.0 azure-nspkg==3.0.2 azure-storage==0.36.0 azure-storage-blob==12.0.0

What problem was encountered?

When i create container correctly than code said that "Tuple timeout setting is deprecated".

What is the meaning this? how i solve it. Thank you....

xiafu-msft commented 4 years ago

Hi @AliYmn

Thanks for reaching out. Your pip result looks weird, would you like to create another virtual environment and only do pip install azure-storage-blob.

Here is the README of version 12.0.0 https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/storage/azure-storage-blob/README.md

Here is the Api doc for version 12.0.0 https://azuresdkdocs.blob.core.windows.net/$web/python/azure-storage-blob/12.0.0b5/azure.storage.blob.html

Feel free to let me know if it doesn’t help!

solita-tvoipio commented 4 years ago

@AliYmn TL;DR: Set the timeout explicitly by passing a keyword argument connection_timeout=90 (or whatever timeout you want, in seconds) to the the method of ContainerClient you use to create the container (probably also works if you pass it to the constructor of ContainerClient, but I did not try that).

@xiafu-msft I have the same issue as AliYmn. pip freeze | grep azure gives azure-core==1.1.0 azure-storage-blob==12.0.0

I did a bit of tracing, and it seems that the error is due to lines 13-21 of azure/storage/blob/_shared/constants.py :

DEFAULT_SOCKET_TIMEOUT = 20

# for python 3.5+, there was a change to the definition of the socket timeout (as far as socket.sendall is concerned)
# The socket timeout is now the maximum total duration to send all data.
if sys.version_info >= (3, 5):
    # the timeout to connect is 20 seconds, and the read timeout is 2000 seconds
    # the 2000 seconds was calculated with: 100MB (max block size)/ 50KB/s (an arbitrarily chosen minimum upload speed)
    DEFAULT_SOCKET_TIMEOUT = (20, 2000) # type: ignore

This DEFAULT_SOCKET_TIMEOUT is used in azure/storage/blob/_shared/base_client.py in _create_pipeline() which is invoked by the constructor of StorageAccountHostsMixin. If the kwarg connection_timeout is not passed to the constructor, then the DEFAULT_SOCKET_TIMEOUT is used to set the value of kwargs["connection_timeout"], kwargs is passed on to RequestsTransport, and kwargs["connection_timeout"] is used to set the timeout property of self.connection_config. self.connection_config is used by RequestsTransport.send() which finally notices that using a tuple is deprecated and a warning is logged on line 233 of azure/core/pipeline/transport/_requests_basic.py.

Phew.

Maybe the process which Azure teams use to manage deprecations should be looked at? This seems like the deprecation of tuple timeouts was not communicated clearly enough and new releases are not tested very thoroughly against various (valid) versions of dependencies.

AliYmn commented 4 years ago

@xiafu-msft @solita-voipio thank you for all. Maybe i had a lot of package , its come some error. I created new virtualenv, and than it work correctly.