port-ocean 0.12.2.dev13__py3-none-any.whl → 0.12.2.dev15__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.
Potentially problematic release.
This version of port-ocean might be problematic. Click here for more details.
- port_ocean/utils/repeat.py +20 -24
- {port_ocean-0.12.2.dev13.dist-info → port_ocean-0.12.2.dev15.dist-info}/METADATA +1 -1
- {port_ocean-0.12.2.dev13.dist-info → port_ocean-0.12.2.dev15.dist-info}/RECORD +6 -6
- {port_ocean-0.12.2.dev13.dist-info → port_ocean-0.12.2.dev15.dist-info}/LICENSE.md +0 -0
- {port_ocean-0.12.2.dev13.dist-info → port_ocean-0.12.2.dev15.dist-info}/WHEEL +0 -0
- {port_ocean-0.12.2.dev13.dist-info → port_ocean-0.12.2.dev15.dist-info}/entry_points.txt +0 -0
port_ocean/utils/repeat.py
CHANGED
|
@@ -5,6 +5,7 @@ from traceback import format_exception
|
|
|
5
5
|
from typing import Callable, Coroutine, Any
|
|
6
6
|
|
|
7
7
|
from loguru import logger
|
|
8
|
+
from starlette.concurrency import run_in_threadpool
|
|
8
9
|
|
|
9
10
|
from port_ocean.utils.signal import signal_handler
|
|
10
11
|
|
|
@@ -15,10 +16,6 @@ NoArgsNoReturnDecorator = Callable[
|
|
|
15
16
|
]
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
def run_in_threadpool(param):
|
|
19
|
-
pass
|
|
20
|
-
|
|
21
|
-
|
|
22
19
|
def repeat_every(
|
|
23
20
|
seconds: float,
|
|
24
21
|
wait_first: bool = False,
|
|
@@ -61,27 +58,26 @@ def repeat_every(
|
|
|
61
58
|
async def loop() -> None:
|
|
62
59
|
nonlocal repetitions
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
61
|
+
if wait_first:
|
|
62
|
+
await asyncio.sleep(seconds)
|
|
63
|
+
while max_repetitions is None or repetitions < max_repetitions:
|
|
64
|
+
# count the repetition even if an exception is raised
|
|
65
|
+
repetitions += 1
|
|
66
|
+
try:
|
|
67
|
+
if is_coroutine:
|
|
68
|
+
task = asyncio.create_task(func())
|
|
69
|
+
signal_handler.register(lambda: task.cancel())
|
|
70
|
+
ensure_future(task)
|
|
71
|
+
else:
|
|
72
|
+
await run_in_threadpool(func)
|
|
73
|
+
except Exception as exc:
|
|
74
|
+
formatted_exception = "".join(
|
|
75
|
+
format_exception(type(exc), exc, exc.__traceback__)
|
|
76
|
+
)
|
|
77
|
+
logger.error(formatted_exception)
|
|
78
|
+
if raise_exceptions:
|
|
79
|
+
raise exc
|
|
82
80
|
await asyncio.sleep(seconds)
|
|
83
|
-
if max_repetitions is None or repetitions < max_repetitions:
|
|
84
|
-
asyncio.get_event_loop().call_later(seconds, loop)
|
|
85
81
|
|
|
86
82
|
ensure_future(loop())
|
|
87
83
|
|
|
@@ -135,12 +135,12 @@ port_ocean/utils/async_iterators.py,sha256=iw3cUHxfQm3zUSPdw2FmSXDU8E1Ppnys4TGhs
|
|
|
135
135
|
port_ocean/utils/cache.py,sha256=3KItZDE2yVrbVDr-hoM8lNna8s2dlpxhP4ICdLjH4LQ,2231
|
|
136
136
|
port_ocean/utils/misc.py,sha256=0q2cJ5psqxn_5u_56pT7vOVQ3shDM02iC1lzyWQ_zl0,2098
|
|
137
137
|
port_ocean/utils/queue_utils.py,sha256=KWWl8YVnG-glcfIHhM6nefY-2sou_C6DVP1VynQwzB4,2762
|
|
138
|
-
port_ocean/utils/repeat.py,sha256=
|
|
138
|
+
port_ocean/utils/repeat.py,sha256=oD0_M2DyL7VNIGrGsogtolhboL1Td9jONJAzmSuWk2M,3412
|
|
139
139
|
port_ocean/utils/signal.py,sha256=z9iJBw8aAfxGKwlSHjhEq1g8HbPkCaYpVMyvtisrjZU,1365
|
|
140
140
|
port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
|
|
141
141
|
port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
|
|
142
|
-
port_ocean-0.12.2.
|
|
143
|
-
port_ocean-0.12.2.
|
|
144
|
-
port_ocean-0.12.2.
|
|
145
|
-
port_ocean-0.12.2.
|
|
146
|
-
port_ocean-0.12.2.
|
|
142
|
+
port_ocean-0.12.2.dev15.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
143
|
+
port_ocean-0.12.2.dev15.dist-info/METADATA,sha256=JUHccdsBpTpfeHsoyT9NZ2_ZLGavGOHpibY_FdtDuxQ,6713
|
|
144
|
+
port_ocean-0.12.2.dev15.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
145
|
+
port_ocean-0.12.2.dev15.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
|
|
146
|
+
port_ocean-0.12.2.dev15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|