Skip to content

Commit

Permalink
update polling interval (Azure#19119)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapratico authored Jun 4, 2021
1 parent d1337f2 commit 0331778
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
)
from ._user_agent import USER_AGENT
from ._polling import TranslationPolling, DocumentTranslationLROPollingMethod
from ._helpers import get_http_logging_policy, convert_datetime, get_authentication_policy, get_translation_input
from ._helpers import (
get_http_logging_policy,
convert_datetime,
get_authentication_policy,
get_translation_input,
POLLING_INTERVAL
)
if TYPE_CHECKING:
from azure.core.paging import ItemPaged
from azure.core.credentials import TokenCredential, AzureKeyCredential
Expand Down Expand Up @@ -64,14 +70,15 @@ def __init__(self, endpoint, credential, **kwargs):
self._api_version = kwargs.pop('api_version', None)

authentication_policy = get_authentication_policy(credential)

polling_interval = kwargs.pop("polling_interval", POLLING_INTERVAL)
self._client = _BatchDocumentTranslationClient(
endpoint=endpoint,
credential=credential, # type: ignore
api_version=self._api_version,
sdk_moniker=USER_AGENT,
authentication_policy=authentication_policy,
http_logging_policy=get_http_logging_policy(),
polling_interval=polling_interval,
**kwargs
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
)
from ._models import DocumentTranslationInput
COGNITIVE_KEY_HEADER = "Ocp-Apim-Subscription-Key"
POLLING_INTERVAL = 1


def get_translation_input(args, kwargs, continuation_token):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
FileFormat,
DocumentStatusResult
)
from .._helpers import get_http_logging_policy, convert_datetime, get_authentication_policy, get_translation_input
from .._helpers import (
get_http_logging_policy,
convert_datetime,
get_authentication_policy,
get_translation_input,
POLLING_INTERVAL
)
from ._async_polling import AsyncDocumentTranslationLROPollingMethod, AsyncDocumentTranslationLROPoller
from .._polling import TranslationPolling
if TYPE_CHECKING:
Expand Down Expand Up @@ -67,13 +73,15 @@ def __init__(
self._api_version = kwargs.pop('api_version', None)

authentication_policy = get_authentication_policy(credential)
polling_interval = kwargs.pop("polling_interval", POLLING_INTERVAL)
self._client = _BatchDocumentTranslationClient(
endpoint=endpoint,
credential=credential, # type: ignore
api_version=self._api_version,
sdk_moniker=USER_AGENT,
authentication_policy=authentication_policy,
http_logging_policy=get_http_logging_policy(),
polling_interval=polling_interval,
**kwargs
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def create_resource(self, name, **kwargs):
# set polling interval to 0 for recorded tests
if not self.is_live:
self.client_kwargs["polling_interval"] = 0
else:
# default is 30s, but our tests translate very small docs so this helps speed up live testing
self.client_kwargs["polling_interval"] = 5

client = self.client_cls(
doctranslation_test_endpoint,
Expand Down

0 comments on commit 0331778

Please sign in to comment.