Skip to content

Commit

Permalink
Source Bing Ads: backoff socket.timeout (airbytehq#16335)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
  • Loading branch information
grubberr authored and jhammarstedt committed Oct 31, 2022
1 parent b538963 commit ceb9378
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
- name: Bing Ads
sourceDefinitionId: 47f25999-dd5e-4636-8c39-e7cea2453331
dockerRepository: airbyte/source-bing-ads
dockerImageTag: 0.1.11
dockerImageTag: 0.1.12
documentationUrl: https://docs.airbyte.io/integrations/sources/bing-ads
icon: bingads.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@
- "overwrite"
- "append"
- "append_dedup"
- dockerImage: "airbyte/source-bing-ads:0.1.11"
- dockerImage: "airbyte/source-bing-ads:0.1.12"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/bing-ads"
connectionSpecification:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-bing-ads/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.11
LABEL io.airbyte.version=0.1.12
LABEL io.airbyte.name=airbyte/source-bing-ads
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

import socket
import sys
from datetime import datetime, timedelta, timezone
from functools import lru_cache
from typing import Any, Iterator, Mapping, Optional
from urllib.error import URLError

import backoff
import pendulum
Expand Down Expand Up @@ -94,6 +96,9 @@ def is_token_expiring(self) -> bool:
return False if token_updated_expires_in > self.refresh_token_safe_delta else True

def should_retry(self, error: WebFault) -> bool:
if isinstance(error, URLError) and isinstance(error.reason, socket.timeout):
return False

error_code = str(errorcode_of_exception(error))
give_up = error_code not in self.retry_on_codes
if give_up:
Expand All @@ -112,7 +117,7 @@ def log_retry_attempt(self, details: Mapping[str, Any]) -> None:
def request(self, **kwargs: Mapping[str, Any]) -> Mapping[str, Any]:
return backoff.on_exception(
backoff.expo,
WebFault,
(WebFault, URLError),
max_tries=self.max_retries,
factor=self.retry_factor,
jitter=None,
Expand Down
3 changes: 2 additions & 1 deletion docs/integrations/sources/bing-ads.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ API limits number of requests for all Microsoft Advertising clients. You can fin

| Version | Date | Pull Request | Subject |
| :------ | :--------- | :------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------- |
| 0.1.11 | 2022-08-25 | [15684](https://github.com/airbytehq/airbyte/pull/15684) (published in [15987](https://github.com/airbytehq/airbyte/pull/15987))| Fixed log messages being unreadable |
| 0.1.12 | 2022-09-05 | [16335](https://github.com/airbytehq/airbyte/pull/16335) | Added backoff for socket.timeout |
| 0.1.11 | 2022-08-25 | [15684](https://github.com/airbytehq/airbyte/pull/15684) (published in [15987](https://github.com/airbytehq/airbyte/pull/15987))| Fixed log messages being unreadable |
| 0.1.10 | 2022-08-12 | [15602](https://github.com/airbytehq/airbyte/pull/15602) | Fixed bug caused Hourly Reports to crash due to invalid fields set |
| 0.1.9 | 2022-08-02 | [14862](https://github.com/airbytehq/airbyte/pull/14862) | Added missing columns |
| 0.1.8 | 2022-06-15 | [13801](https://github.com/airbytehq/airbyte/pull/13801) | All reports `hourly/daily/weekly/monthly` will be generated by default, these options are removed from input configuration |
Expand Down

0 comments on commit ceb9378

Please sign in to comment.