Skip to content

Commit 6f53b9c

Browse files
[textanalytics] fix for 429 (#24279)
* try fix for 429 * revert
1 parent d989621 commit 6f53b9c

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_base_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def __init__(
6969
"$top",
7070
"$skip",
7171
"opinionMining",
72+
"api-version"
7273
}
7374
)
7475
try:

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_policies.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ def on_response(self, request, response):
2828
data = ContentDecodePolicy.deserialize_from_http_generics(
2929
response.http_response
3030
)
31-
if self._is_lro and (not data or data.get("status") not in _FINISHED):
31+
if self._is_lro and (not data or data.get("status", "").lower() not in _FINISHED):
32+
return
33+
if response.http_response.status_code == 429:
3234
return
3335
if data:
3436
inner = data.get("results", data) # language API compat
3537
statistics = inner.get("statistics", None)
3638
model_version = inner.get("modelVersion", None)
37-
38-
if statistics or model_version:
39-
batch_statistics = TextDocumentBatchStatistics._from_generated( # pylint: disable=protected-access
40-
statistics
41-
)
42-
response.statistics = batch_statistics
43-
response.model_version = model_version
39+
batch_statistics = TextDocumentBatchStatistics._from_generated( # pylint: disable=protected-access
40+
statistics
41+
)
42+
response.statistics = batch_statistics
43+
response.model_version = model_version
4444
response.raw_response = data
4545
self._response_callback(response)

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_base_client_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(
5757
"$top",
5858
"$skip",
5959
"opinionMining",
60+
"api-version"
6061
}
6162
)
6263
try:

0 commit comments

Comments
 (0)