File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ def __init__(
100
100
self ._is_closed = False
101
101
self ._on_link_state_change = kwargs .get ("on_link_state_change" )
102
102
self ._on_attach = kwargs .get ("on_attach" )
103
- self ._error = None
103
+ self ._error : Optional [ AMQPLinkError ] = None
104
104
105
105
async def __aenter__ (self ) -> "Link" :
106
106
await self .attach ()
@@ -244,6 +244,11 @@ async def _incoming_detach(self, frame) -> None:
244
244
self ._error = error_cls (condition = frame [2 ][0 ], description = frame [2 ][1 ], info = frame [2 ][2 ])
245
245
await self ._set_state (LinkState .ERROR )
246
246
else :
247
+ if self .state != LinkState .DETACH_SENT :
248
+ # Handle the case of when the remote side detaches without sending an error.
249
+ # We should detach as per the spec but then retry connecting
250
+ self ._error = AMQPLinkError (condition = ErrorCondition .UnknownError ,
251
+ description = "Link detached unexpectedly." , retryable = True )
247
252
await self ._set_state (LinkState .DETACHED )
248
253
249
254
async def attach (self ) -> None :
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ def __init__(
96
96
self ._is_closed = False
97
97
self ._on_link_state_change = kwargs .get ("on_link_state_change" )
98
98
self ._on_attach = kwargs .get ("on_attach" )
99
- self ._error = None
99
+ self ._error : Optional [ AMQPLinkError ] = None
100
100
101
101
def __enter__ (self ) -> "Link" :
102
102
self .attach ()
@@ -239,6 +239,11 @@ def _incoming_detach(self, frame) -> None:
239
239
self ._error = error_cls (condition = frame [2 ][0 ], description = frame [2 ][1 ], info = frame [2 ][2 ])
240
240
self ._set_state (LinkState .ERROR )
241
241
else :
242
+ if self .state != LinkState .DETACH_SENT :
243
+ # Handle the case of when the remote side detaches without sending an error.
244
+ # We should detach as per the spec but then retry connecting
245
+ self ._error = AMQPLinkError (condition = ErrorCondition .UnknownError ,
246
+ description = "Link detached unexpectedly." , retryable = True )
242
247
self ._set_state (LinkState .DETACHED )
243
248
244
249
def attach (self ) -> None :
You can’t perform that action at this time.
0 commit comments