omnata-plugin-runtime 0.8.0a189__py3-none-any.whl → 0.8.0a191__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- omnata_plugin_runtime/plugin_entrypoints.py +1 -1
- omnata_plugin_runtime/rate_limiting.py +15 -9
- {omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a191.dist-info}/METADATA +1 -1
- {omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a191.dist-info}/RECORD +6 -6
- {omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a191.dist-info}/LICENSE +0 -0
- {omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a191.dist-info}/WHEEL +0 -0
@@ -84,6 +84,7 @@ class PluginEntrypoint:
|
|
84
84
|
|
85
85
|
|
86
86
|
def sync(self, sync_request: Dict):
|
87
|
+
request = TypeAdapter(SyncRequestPayload).validate_python(sync_request)
|
87
88
|
logger.add_extra('omnata.operation', 'sync')
|
88
89
|
logger.add_extra('omnata.sync.id', request.sync_id)
|
89
90
|
logger.add_extra('omnata.sync.direction', request.sync_direction)
|
@@ -95,7 +96,6 @@ class PluginEntrypoint:
|
|
95
96
|
with tracer.start_as_current_span("initialization") as span:
|
96
97
|
span.add_event("Fetching secrets")
|
97
98
|
|
98
|
-
request = TypeAdapter(SyncRequestPayload).validate_python(sync_request)
|
99
99
|
connection_secrets = get_secrets(
|
100
100
|
request.oauth_secret_name, request.other_secrets_name
|
101
101
|
)
|
@@ -19,6 +19,9 @@ from .logging import logger
|
|
19
19
|
import pytz
|
20
20
|
from requests.adapters import HTTPAdapter
|
21
21
|
from urllib3.util.retry import Retry
|
22
|
+
from opentelemetry import trace
|
23
|
+
|
24
|
+
tracer = trace.get_tracer(__name__)
|
22
25
|
|
23
26
|
TimeUnitType = Literal["second", "minute", "hour", "day"]
|
24
27
|
|
@@ -383,11 +386,12 @@ class RetryWithLogging(Retry):
|
|
383
386
|
retry_after = self.get_retry_after(response)
|
384
387
|
if retry_after:
|
385
388
|
logger.info(f"Retrying after {retry_after} seconds due to Retry-After header")
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
389
|
+
with tracer.start_as_current_span("http_retry_wait"):
|
390
|
+
if self.thread_cancellation_token is None:
|
391
|
+
time.sleep(retry_after)
|
392
|
+
else:
|
393
|
+
if self.thread_cancellation_token.wait(retry_after):
|
394
|
+
raise InterruptedWhileWaitingException(message="The sync was interrupted while waiting for rate limiting to expire")
|
391
395
|
return True
|
392
396
|
return False
|
393
397
|
|
@@ -504,8 +508,9 @@ class RateLimitedSession(requests.Session):
|
|
504
508
|
raise InterruptedWhileWaitingException(message=f"The rate limiting wait time ({wait_time} seconds) would exceed the run deadline")
|
505
509
|
logger.info(f"Waiting for {wait_time} seconds before retrying {method} request to {url}")
|
506
510
|
# if wait() returns true, it means that the thread was cancelled
|
507
|
-
|
508
|
-
|
511
|
+
with tracer.start_as_current_span("http_retry_wait"):
|
512
|
+
if self.thread_cancellation_token.wait(wait_time):
|
513
|
+
raise InterruptedWhileWaitingException(message="The sync was interrupted while waiting for rate limiting to expire")
|
509
514
|
else:
|
510
515
|
current_url_retries = self.increment_retries(url)
|
511
516
|
if current_url_retries >= self.max_retries:
|
@@ -514,8 +519,9 @@ class RateLimitedSession(requests.Session):
|
|
514
519
|
if datetime.datetime.now(pytz.UTC) + datetime.timedelta(seconds=backoff_time) > self.run_deadline:
|
515
520
|
raise InterruptedWhileWaitingException(message=f"The rate limiting backoff time ({backoff_time} seconds) would exceed the run deadline")
|
516
521
|
logger.info(f"Waiting for {backoff_time} seconds before retrying {method} request to {url}")
|
517
|
-
|
518
|
-
|
522
|
+
with tracer.start_as_current_span("http_retry_wait"):
|
523
|
+
if self.thread_cancellation_token.wait(backoff_time):
|
524
|
+
raise InterruptedWhileWaitingException(message="The sync was interrupted while waiting for rate limiting backoff")
|
519
525
|
else:
|
520
526
|
self.set_retries(url,0) # Reset retries if the request is successful
|
521
527
|
return response
|
{omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a191.dist-info}/RECORD
RENAMED
@@ -4,9 +4,9 @@ omnata_plugin_runtime/configuration.py,sha256=uMGMqKYy4XmntX1ROungUwTJXeY2ciczAb
|
|
4
4
|
omnata_plugin_runtime/forms.py,sha256=ueodN2GIMS5N9fqebpY4uNGJnjEb9HcuaVQVfWH-cGg,19838
|
5
5
|
omnata_plugin_runtime/logging.py,sha256=u_Bo2v4jS3C_2E_Y8a7yfZZcIP-h5Mak_FPnFHUwFbU,4378
|
6
6
|
omnata_plugin_runtime/omnata_plugin.py,sha256=aggjb_CTTjhgqjS8CHPOm4ENU0jNcYoT6LC8yI1IeF4,130048
|
7
|
-
omnata_plugin_runtime/plugin_entrypoints.py,sha256=
|
8
|
-
omnata_plugin_runtime/rate_limiting.py,sha256=
|
9
|
-
omnata_plugin_runtime-0.8.
|
10
|
-
omnata_plugin_runtime-0.8.
|
11
|
-
omnata_plugin_runtime-0.8.
|
12
|
-
omnata_plugin_runtime-0.8.
|
7
|
+
omnata_plugin_runtime/plugin_entrypoints.py,sha256=LZHwOsacZmS6JtzNM3OsLvpYyVo_UP0DaCWDWDxrJ0w,32756
|
8
|
+
omnata_plugin_runtime/rate_limiting.py,sha256=6fn_h2vxcHbqqiW-OZ6FKfNYv_XlNvorsrCknVce2PA,25929
|
9
|
+
omnata_plugin_runtime-0.8.0a191.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
|
10
|
+
omnata_plugin_runtime-0.8.0a191.dist-info/METADATA,sha256=2TmcYIQw_-i9nQAuKm8EQUHamk6Tuzyg_yxwaxlT2H4,2148
|
11
|
+
omnata_plugin_runtime-0.8.0a191.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
12
|
+
omnata_plugin_runtime-0.8.0a191.dist-info/RECORD,,
|
{omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a191.dist-info}/LICENSE
RENAMED
File without changes
|
{omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a191.dist-info}/WHEEL
RENAMED
File without changes
|