Skip to content

Commit

Permalink
Retry on requests.exceptions.ConnectionError (again) (#282)
Browse files Browse the repository at this point in the history
In a previous PR, we switched from retrying on requests connection
errors to the internal Cognite exceptions that wrapped these. This
fixed some of the issues encountered by the customer (SLB).

But, in some corner cases, such as for authorization, you can still
get an unwrapped requests.exceptions.ConnectionError (as seen by
the customer).

This re-adds the retry on ConnectionError in addition to the internal
Cognite SDK classes, to be more resilient.
  • Loading branch information
thorkildcognite authored Jan 12, 2024
1 parent e4ffd46 commit 6e228db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [6.3.1]

### Fixed

* Improved the state store retry behavior to handle both fundamental
and wrapped network connection errors.

## [6.3.0]

### Added
Expand Down
8 changes: 5 additions & 3 deletions cognite/extractorutils/statestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
from types import TracebackType
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union

from requests.exceptions import ConnectionError

from cognite.client import CogniteClient
from cognite.client.exceptions import CogniteAPIError, CogniteException
from cognite.extractorutils.uploader import DataPointList
Expand Down Expand Up @@ -346,7 +348,7 @@ def __init__(
self._ensure_table()

@retry(
exceptions=(CogniteException,),
exceptions=(CogniteException, ConnectionError),
tries=RETRIES,
delay=RETRY_DELAY,
max_delay=RETRY_MAX_DELAY,
Expand All @@ -368,7 +370,7 @@ def initialize(self, force: bool = False) -> None:
self._initialize_implementation(force)

@retry(
exceptions=(CogniteException,),
exceptions=(CogniteException, ConnectionError),
tries=RETRIES,
delay=RETRY_DELAY,
max_delay=RETRY_MAX_DELAY,
Expand Down Expand Up @@ -402,7 +404,7 @@ def synchronize(self) -> None:
self._synchronize_implementation()

@retry(
exceptions=(CogniteException,),
exceptions=(CogniteException, ConnectionError),
tries=RETRIES,
delay=RETRY_DELAY,
max_delay=RETRY_MAX_DELAY,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cognite-extractor-utils"
version = "6.3.0"
version = "6.3.1"
description = "Utilities for easier development of extractors for CDF"
authors = ["Mathias Lohne <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 6e228db

Please sign in to comment.