Bug Description
It would be nice if this could be supported, I have implemented it myself now in a wrapper for HttpStream. If anyone is interested in it:
class CustomHttpStream(HttpStream):
def __init__(self, client: ApiClient, ref: ConversationReference):
super().__init__(client, ref)
self._is_canceled = False
def emit(self, activity: Union[MessageActivityInput, TypingActivityInput, str]) -> None:
if self.is_canceled():
logger.warning("Not emitting activity, stream is canceled.")
return None
return super().emit(activity)
async def _send(self, to_send: Union[TypingActivityInput, MessageActivityInput]) -> SentActivity:
try:
res = await super()._send(to_send)
return res
except HTTPStatusError as e:
if e.response.status_code == 403:
# Set canceled and return a `CancelledError` so that the
# request won't be retried.
self._is_canceled = True
logger.warning("Teams channel stopped the stream.")
raise asyncio.CancelledError("Teams channel stopped the stream.")
raise e
except Exception as e:
raise e
def is_canceled(self) -> bool:
return self._is_canceled
Steps to Reproduce
- Start a stream
- Send messages
- Cancel from Teams
HttpStream tries to continue sending updates in a retry, no way to see that it was canceled
Expected Behavior
HttpStream should stop attempt sending updates, and it should be possible to see that it was canceled.
Actual Behavior
HttpStream tries to continue sending updates in a retry, there is no way to see that it was canceled
SDK Version
20.0.0a20
Python Version
3.14.2
Additional Context
No response
Bug Description
It would be nice if this could be supported, I have implemented it myself now in a wrapper for
HttpStream. If anyone is interested in it:Steps to Reproduce
HttpStreamtries to continue sending updates in a retry, no way to see that it was canceledExpected Behavior
HttpStreamshould stop attempt sending updates, and it should be possible to see that it was canceled.Actual Behavior
HttpStreamtries to continue sending updates in a retry, there is no way to see that it was canceledSDK Version
20.0.0a20
Python Version
3.14.2
Additional Context
No response