Skip to content

Commit

Permalink
Merge pull request #98 from SEKOIA-IO/feat/generic_action_improve_retry
Browse files Browse the repository at this point in the history
feat: Improve retry for generic actions
Darkheir authored Nov 28, 2023
2 parents 8408477 + 70b94df commit 996e5a5
Showing 5 changed files with 266 additions and 244 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.8.2] - 2023-11-28

## Changed

- Improve retry for generic actions

## [1.8.1] - 2023-11-20

### Fixed
494 changes: 255 additions & 239 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "sekoia-automation-sdk"

version = "1.8.1"
version = "1.8.2"
description = "SDK to create Sekoia.io playbook modules"
license = "MIT"
readme = "README.md"
6 changes: 3 additions & 3 deletions sekoia_automation/action.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
import requests
import sentry_sdk
from pydantic import validate_arguments
from requests import Response, Timeout
from requests import RequestException, Response
from tenacity import (
RetryError,
Retrying,
@@ -334,9 +334,9 @@ def run(self, arguments) -> dict | None:

try:
for attempt in Retrying(
stop=stop_after_attempt(5),
stop=stop_after_attempt(10),
wait=self._wait_param(),
retry=retry_if_exception_type(Timeout),
retry=retry_if_exception_type((RequestException, OSError)),
):
with attempt:
response: Response = requests.request(
2 changes: 1 addition & 1 deletion tests/test_action.py
Original file line number Diff line number Diff line change
@@ -319,7 +319,7 @@ def init_action():
results: dict = action.run(arguments)

assert results is None
assert mock.call_count == 5
assert mock.call_count == 10

# Makes sure `*_path` have been recursively replaced
action = init_action()

0 comments on commit 996e5a5

Please sign in to comment.