[servicebus] Async ServiceBusSender leaks AttributeError ('NoneType' has no attribute 'client_ready_async') after idle timeout, instead of ServiceBusConnectionError
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- azure, python
- Domain
- cloud, distributed-systems
Research direction
Start at the async ServiceBusSender send_messages path and trace how an idle-disconnected link leaves the internal _handler as None. Add a regression test for a single-threaded send after the idle-timeout condition, then verify that it raises ServiceBusConnectionError rather than AttributeError or reconnects transparently.
Written by the indexing model from the issue text.
Description
Related issues
Same root cause as #35618 and #36334 (internal _handler reset to None),
but a different trigger: those reproduce under concurrent sends and were
closed not_planned with an asyncio.Lock() workaround. This report is a
single-threaded, non-concurrent reproduction driven by Azure's ~10-minute
idle timeout — the lock workaround does not apply.
Describe the bug
A long-lived (singleton) async ServiceBusSender that is reused across sends
works fine until the connection sits idle past Azure's ~10-minute idle timeout.
The next send_messages() raises:
AttributeError: 'NoneType' object has no attribute 'client_ready_async'
Expected: a documented, catchable ServiceBusConnectionError (or transparent
implicit reconnect), so callers can distinguish "stale link, safe to recreate
and retry" from a genuine error (auth/quota/payload).
Because the leaked exception is a bare AttributeError, callers cannot reliably
tell it apart from an ordinary programming bug without string-matching on the
internal attribute name client_ready_async, which is fragile across releases.
Steps to reproduce
- Create an async
ServiceBusClient, then oneServiceBusSender, and keep both. await sender.send_messages(...)once — succeeds.- Leave the sender idle for > 10 minutes (Azure idle timeout drops the AMQP link).
await sender.send_messages(...)again.
Result: AttributeError: 'NoneType' object has no attribute 'client_ready_async'
rather than a ServiceBusConnectionError.
Minimal sketch:
import asyncio
from azure.servicebus.aio import ServiceBusClient
from azure.servicebus import ServiceBusMessage
async def main():
client = ServiceBusClient.from_connection_string(CONN_STR)
sender = client.get_queue_sender(QUEUE)
await sender.send_messages(ServiceBusMessage("first")) # ok
await asyncio.sleep(11 * 60) # exceed idle timeout
await sender.send_messages(ServiceBusMessage("second")) # AttributeError
asyncio.run(main())
Expected behavior
The idle-dropped link should surface as ServiceBusConnectionError (the SDK's
documented connection-loss exception), or the sender should reconnect implicitly.
Either way, no internal AttributeError should escape.
Environment
azure-servicebus: 7.14.3 (latest stable)
azure-core: 1.38.2
Python: 3.11.14
OS: Windows 11 (also observed in Linux containers)
Transport: async (azure.servicebus.aio), pure-Python AMQP
Impact / current workaround
We run one persistent sender per worker and must detect this failure to recreate
the sender and retry. Since no typed exception is raised, we string-match:
isinstance(exc, AttributeError) and "client_ready_async" in str(exc)
This is brittle — it depends on an internal attribute name. A typed exception
(or implicit reconnect) would let us delete the string match. Please consider
fixing the idle-timeout path specifically, independently of the concurrency
scenarios in
Azure/azure-sdk-for-python#35618 /
Azure/azure-sdk-for-python#36334.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 3.4k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 189
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/azure-sdk-for-python
-
needs-triage
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Azure/azure-sdk-for-python#50155 · 1 reaction ·
Maintainers usually reply within 1 day
-
[Teams Chatbot]: next-mypy install 404s should point to CFS auth or --pypi workaroundPossibly taken @jianingwang123 claimed this 16 days ago. Openneeds-triage
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
Azure/azure-sdk-for-python#49886 · 1 comment · 2 reactions · 2 assignees ·
Maintainers usually reply within 1 day
-
[AI Projects] AIProjectInstrumentor: non-streamed responses.create raises AttributeError ('NonRecordingSpan' object has no attribute 'attributes') when the span is not sampledPossibly taken @14H034160212 claimed this 19 days ago. OpenAI Projects Client customer-reported question
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Azure/azure-sdk-for-python#49854 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
azure-eventhub migration guide: legacy checkpoint sample writes "None" metadata for partitions that were never checkpointedPossibly taken @hidingmyname claimed this 27 days ago. OpenClient customer-reported Event Hubs needs-team-attention question Service Attention
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Azure/azure-sdk-for-python#49723 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Scheduled test pipelines fail at the Analyze_Test stage due to date formattingPossibly taken A pull request linked to this issue is open or already merged. OpenEngSys
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Azure/azure-sdk-for-python#49614 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
All issues in Azure/azure-sdk-for-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vllm-project/vllm#70030 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
TigreGotico/tugaphone#408 ·
Maintainers usually reply within 1 day
-
t: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
bug (unverified)
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
scikit-hep/awkward#4581 · 1 comment ·
Maintainers usually reply within 1 day