Azure-sdk-for-python: QueueClient logs "Tuple timeout setting is deprecated"

Created on 27 Nov 2019  路  9Comments  路  Source: Azure/azure-sdk-for-python

Python 3.5.3
$ pip3 list | grep azure
azure-common (1.1.23)
azure-core (1.1.0)
azure-storage-common (2.1.0)
azure-storage-queue (12.0.0)

Using QueueClient causes logging output "Tuple timeout setting is deprecated":

>>> from azure.storage.queue import QueueClient
>>> q = QueueClient(account_url="https://myaccount.queue.core.windows.net", credential="my_key", queue_name="my_queue")
>>> q.get_queue_properties()
Tuple timeout setting is deprecated
{'approximate_message_count': 0, 'metadata': {}, 'name': 'my_queue'}
>>>
>>> msgs = q.receive_messages()
>>> for msg in msgs:
...     print(msg.content)
...
Tuple timeout setting is deprecated
>>>
>>> q.get_queue_properties(timeout=5)
Tuple timeout setting is deprecated
{'name': 'my_queue', 'approximate_message_count': 0, 'metadata': {}}
>>>

The output is generated in azure/core/pipeline/transport/_requests_basic.py:

            connection_timeout = kwargs.pop('connection_timeout', self.connection_config.timeout)

            if isinstance(connection_timeout, tuple):
                if 'read_timeout' in kwargs:
                    raise ValueError('Cannot set tuple connection_timeout and read_timeout together')
                _LOGGER.warning("Tuple timeout setting is deprecated")
                timeout = connection_timeout
            else:
                read_timeout = kwargs.pop('read_timeout', self.connection_config.read_timeout)
                timeout = (connection_timeout, read_timeout)

In azure/storage/queue/_shared/constants.py I see the definitions:

# Socket timeout in seconds
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

Commenting out the definition for the tuple variant of DEFAULT_SOCKET_TIMEOUT prevents the output in my cases. However, in azure/storage/queue/_shared/base_client_async.py I see code that will fail in that case:

    def _create_pipeline(self, credential, **kwargs):
        ...
        if 'connection_timeout' not in kwargs:
            kwargs['connection_timeout'] = DEFAULT_SOCKET_TIMEOUT[0] # type: ignore

So, one piece of code sets the tuple, second piece of code complains that tuple is deprecated, and third piece of code fails if tuple is not there.

While waiting for the code fix for this, can anyone tell, where should I manually set the connection_timeout argument to prevent the logging output?

Client Storage customer-reported

Most helpful comment

@markkuleinio Thanks for reporting. The fix has been pushed and will be released in the upcoming release.

cc: @xiafu-msft

All 9 comments

Found the workaround. In https://azuresdkdocs.blob.core.windows.net/$web/python/azure-storage-queue/12.0.0/azure.storage.queue.html#azure.storage.queue.QueueClient there is no mention but https://azuresdkdocs.blob.core.windows.net/$web/python/azure-storage-queue/12.0.0/index.html#other-client-per-operation-configuration says it, the connection_timeout argument is used with QueueClient:

>>> from azure.storage.queue import QueueClient
>>> q = QueueClient(
...       account_url="https://myaccount.queue.core.windows.net",
...       credential="my_key",
...       queue_name="my_queue",
...       connection_timeout=5)
>>> q.get_queue_properties()
{'name': 'my_queue', 'approximate_message_count': 0, 'metadata': {}}
>>>

@markkuleinio thanks for letting us know! Adding the right team to take a look at this //cc: @rakshith91, @mayurid

Also note that the short URL https://aka.ms/azsdk-python-storage-queue-queueclient (the QueueClient link in https://azuresdkdocs.blob.core.windows.net/$web/python/azure-storage-queue/12.0.0/index.html#clients) goes to 12.0.0b5, not to 12.0.0.

@markkuleinio Thanks for reporting. The fix has been pushed and will be released in the upcoming release.

cc: @xiafu-msft

@markkuleinio Can you confirm this issue is fixed in the latest version? Feel free to close the issue.

Looks fine with azure-storage-queue 12.1.0, thanks!

>>> from azure.storage.queue import QueueClient
>>> q = QueueClient(account_url="https://myaccount.queue.core.windows.net", credential="my_key", queue_name="my_queue")
>>> q.get_queue_properties()
{'approximate_message_count': 0, 'metadata': {}, 'name': 'my_queue'}
>>> for msg in q.receive_messages():
...     print(msg.content)
...
>>>

Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.

Btw https://aka.ms/azsdk-python-storage-queue-queueclient now points to 12.0.0, so it needs manual update again I presume.

thanks for letting us know - updated now!

Was this page helpful?
0 / 5 - 0 ratings