omnata-plugin-runtime 0.8.0a189__py3-none-any.whl → 0.8.0a190__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omnata_plugin_runtime/rate_limiting.py +15 -9
- {omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a190.dist-info}/METADATA +1 -1
- {omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a190.dist-info}/RECORD +5 -5
- {omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a190.dist-info}/LICENSE +0 -0
- {omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a190.dist-info}/WHEEL +0 -0
@@ -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.0a190.dist-info}/RECORD
RENAMED
@@ -5,8 +5,8 @@ omnata_plugin_runtime/forms.py,sha256=ueodN2GIMS5N9fqebpY4uNGJnjEb9HcuaVQVfWH-cG
|
|
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
7
|
omnata_plugin_runtime/plugin_entrypoints.py,sha256=dK2mdH9-HRa4vjCso3SIblC72wRU2txDJJBBwMbruo0,32760
|
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.
|
8
|
+
omnata_plugin_runtime/rate_limiting.py,sha256=6fn_h2vxcHbqqiW-OZ6FKfNYv_XlNvorsrCknVce2PA,25929
|
9
|
+
omnata_plugin_runtime-0.8.0a190.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
|
10
|
+
omnata_plugin_runtime-0.8.0a190.dist-info/METADATA,sha256=NUbYL0R296nnATkJJF4YAV4F8W47yrqiIJ70KNtoSXc,2148
|
11
|
+
omnata_plugin_runtime-0.8.0a190.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
12
|
+
omnata_plugin_runtime-0.8.0a190.dist-info/RECORD,,
|
{omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a190.dist-info}/LICENSE
RENAMED
File without changes
|
{omnata_plugin_runtime-0.8.0a189.dist-info → omnata_plugin_runtime-0.8.0a190.dist-info}/WHEEL
RENAMED
File without changes
|