azure-sdk-for-python: ServiceBusError: Handler failed: 'NoneType' object has no attribute 'settle_messages'
- Package Name: azure-servicebus
- Package Version: 7.10.0
- Operating System: Linux
- Python Version: 3.10.7
Describe the bug
Rarely I am receiving this error ServiceBusError
with this traceback:
File "<string>", line 1, in <module>
File "/app/app.py", line 82, in main
message_handler.listen(
File "/app/app.py", line 138, in listen
for input_ in service_bus_receiver.receive(cancellation=cancellation):
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/possibler/sb/input/receiver.py", line 227, in receive
sb_receiver.complete_message(message)
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/tenacity/__init__.py", line 289, in wrapped_f
return self(f, *args, **kw)
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/tenacity/__init__.py", line 379, in __call__
do = self.iter(retry_state=retry_state)
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/tenacity/__init__.py", line 314, in iter
return fut.result()
File "/root/.pyenv/versions/3.10.7/lib/python3.10/concurrent/futures/_base.py", line 451, in result
return self.__get_result()
File "/root/.pyenv/versions/3.10.7/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
raise self._exception
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/tenacity/__init__.py", line 382, in __call__
result = fn(*args, **kwargs)
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/possibler/sb/input/receiver.py", line 114, in complete_message
return self._entered_receiver.complete_message(*args, **kwargs)
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/azure/servicebus/_servicebus_receiver.py", line 838, in complete_message
self._settle_message_with_retry(message, MESSAGE_COMPLETE)
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/azure/servicebus/_servicebus_receiver.py", line 476, in _settle_message_with_retry
self._do_retryable_operation(
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/azure/servicebus/_base_handler.py", line 418, in _do_retryable_operation
last_exception = self._handle_exception(exception)
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/azure/servicebus/_base_handler.py", line 358, in _handle_exception
raise error
azure.servicebus.exceptions.ServiceBusError: Handler failed: 'NoneType' object has no attribute 'settle_messages'.
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/azure/servicebus/_base_handler.py", line 411, in _do_retryable_operation
return operation(**kwargs)
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/azure/servicebus/_servicebus_receiver.py", line 497, in _settle_message
self._amqp_transport.settle_message_via_receiver_link(
File "/root/.cache/pypoetry/virtualenvs/app-9TtSrW0h-py3.10/lib/python3.10/site-packages/azure/servicebus/_transport/_pyamqp_transport.py", line 701, in settle_message_via_receiver_link
return handler.settle_messages(message._delivery_id, 'accepted')
AttributeError: 'NoneType' object has no attribute 'settle_messages'
I have the receiver.receive_messages()
method wrapped with tenacity retrying which retries the operation on ServiceBusError
, however this issue probably does not seem be solved with retrying.
To Reproduce Steps to reproduce the behavior:
- With
ServiceBusReceiver
receive messages from Service Bus topic subscription
Expected behavior The SDK should either handle such case or implement more robust retrying mechanism.
Additional context
- Using Poetry version 1.3.1
- Running in Azure AKS node pool with image version AKSUbuntu-1804gen2containerd-2022.07.11
- Service Bus Topic subscription lock duration set to 5 minutes
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 33 (11 by maintainers)
@kashifkhan Great, thank you.
Hello @kashifkhan
The modified extract of the code I use:
Hello @kashifkhan , finally the issue occurred again. We have not enabled debug logs, only info. Hope it will be sufficient. Here are the logs:
Hi, I will enable the logging for few weeks, hopefully it will occur again and we will catch it.