kisa-utils 0.42.10__py3-none-any.whl → 0.42.12__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.
- kisa_utils/threads.py +13 -4
- {kisa_utils-0.42.10.dist-info → kisa_utils-0.42.12.dist-info}/METADATA +1 -1
- {kisa_utils-0.42.10.dist-info → kisa_utils-0.42.12.dist-info}/RECORD +5 -5
- {kisa_utils-0.42.10.dist-info → kisa_utils-0.42.12.dist-info}/WHEEL +0 -0
- {kisa_utils-0.42.10.dist-info → kisa_utils-0.42.12.dist-info}/top_level.txt +0 -0
kisa_utils/threads.py
CHANGED
|
@@ -10,6 +10,7 @@ from concurrent import futures
|
|
|
10
10
|
import time
|
|
11
11
|
import datetime
|
|
12
12
|
import threading
|
|
13
|
+
import inspect
|
|
13
14
|
from . import codes
|
|
14
15
|
from .response import Response, Ok, Error
|
|
15
16
|
from typing import Callable
|
|
@@ -129,7 +130,7 @@ def runOnce(function:Callable, *args:tuple, **kwargs:dict) -> Response:
|
|
|
129
130
|
return Error(f'`{function}` is not callable')
|
|
130
131
|
|
|
131
132
|
try:
|
|
132
|
-
return Ok(__executor.run(function, *args, **kwargs))
|
|
133
|
+
return Ok(__executor.run(function, *args, **kwargs).result())
|
|
133
134
|
except Exception as e:
|
|
134
135
|
return Error(f'failed to run task: {e}')
|
|
135
136
|
|
|
@@ -139,7 +140,11 @@ def __loop(function:Callable, duration:float, *args:tuple, **kwargs:dict) -> Non
|
|
|
139
140
|
'''
|
|
140
141
|
while 1:
|
|
141
142
|
time.sleep(duration)
|
|
142
|
-
|
|
143
|
+
try:
|
|
144
|
+
function(*args, **kwargs)
|
|
145
|
+
except Exception as e:
|
|
146
|
+
print(f'`[run-every ERR] `{inspect.getsourcefile(function)}::{function.__name__}` failed with exception: {e}`')
|
|
147
|
+
|
|
143
148
|
|
|
144
149
|
def runEvery(function:Callable, duration:float, *args:tuple, **kwargs:dict) -> dict[str,str|bool]:
|
|
145
150
|
'''
|
|
@@ -178,6 +183,8 @@ def runEvery(function:Callable, duration:float, *args:tuple, **kwargs:dict) -> d
|
|
|
178
183
|
reply['log'] = f'failed to run task: {e}'
|
|
179
184
|
return reply
|
|
180
185
|
|
|
186
|
+
# future.result()
|
|
187
|
+
|
|
181
188
|
reply['status'] = True
|
|
182
189
|
return reply
|
|
183
190
|
|
|
@@ -213,9 +220,10 @@ def __loopRoutineThreads():
|
|
|
213
220
|
|
|
214
221
|
try:
|
|
215
222
|
future = __executor.run(data['function'],*data['args'], **data['kwargs'])
|
|
223
|
+
# future.result()
|
|
216
224
|
currentMinuteData['functionsAlreadyRun'][functionName] = None
|
|
217
225
|
except Exception as e:
|
|
218
|
-
print(f'[routine-loop]: {e}')
|
|
226
|
+
print(f'[routine-loop ERR]: {e}')
|
|
219
227
|
pass
|
|
220
228
|
|
|
221
229
|
def runAt(function:Callable, timesOfDay:list[tuple[int,int]], weekDays:list[int], *args:tuple, tzHoursFromUTC:float = +3.00, **kwargs:dict) -> Response:
|
|
@@ -282,7 +290,8 @@ def __initExecutor():
|
|
|
282
290
|
if __executor: return
|
|
283
291
|
|
|
284
292
|
__executor = __Executor()
|
|
285
|
-
__executor.run(__loopRoutineThreads)
|
|
293
|
+
future = __executor.run(__loopRoutineThreads)
|
|
294
|
+
# future.result()
|
|
286
295
|
|
|
287
296
|
# futures.as_completed([__executor.run(__loopRoutineThreads)])
|
|
288
297
|
|
|
@@ -13,7 +13,7 @@ kisa_utils/remote.py,sha256=0RDrfC4RUW4m6JLziC0_EXJYqzWp38Rw8NDroJ0MuqI,2149
|
|
|
13
13
|
kisa_utils/response.py,sha256=asETUBkeF5OlSTwa-coa7lZDCKmQlHCmHf6eaZFl8CU,4560
|
|
14
14
|
kisa_utils/standardize.py,sha256=nt-uzHQFoKxGscD_MpDYXw65Teg3724whAqa6Kh_zhE,2231
|
|
15
15
|
kisa_utils/storage.py,sha256=6NdEVrHMS7WB_vmCwiGigIinu-EjxalFJhk1kj-_vWs,5990
|
|
16
|
-
kisa_utils/threads.py,sha256=
|
|
16
|
+
kisa_utils/threads.py,sha256=kTUuX32XizEIwHDy9pBRb5CFSzp8pXlQ2T4De0L7S2w,12981
|
|
17
17
|
kisa_utils/token.py,sha256=Y2qglWYWpmHxoXBh-TH0r1as0uPV5LLqMNcunLvM4vM,7850
|
|
18
18
|
kisa_utils/permissions/__config__.py,sha256=i3ELkOydDnjKx2ozQTxLZdZ8DXSeUncnl2kRxANjFmM,613
|
|
19
19
|
kisa_utils/permissions/__init__.py,sha256=iAsGEf5Ktw3gPJ5ZKL8BnuqX8e_S4QgsCVgfaRYi4Qg,48068
|
|
@@ -27,7 +27,7 @@ kisa_utils/servers/flask.py,sha256=XZYY1pWnP1mSvaS5Uv8G3EFJV5BJBQtU2gDbO8suvLc,4
|
|
|
27
27
|
kisa_utils/structures/__init__.py,sha256=JBU1j3A42jQ62ALKnsS1Hav9YXcYwjDw1wQJtohXPbU,83
|
|
28
28
|
kisa_utils/structures/utils.py,sha256=665rXIapGwFqejizeJwy3DryeskCQOdgP25BCdLkGvk,2898
|
|
29
29
|
kisa_utils/structures/validator.py,sha256=oCSgY_itst6bZdC5g8yVU4-lSH2xnUsOx3X-oPyV7nA,4626
|
|
30
|
-
kisa_utils-0.42.
|
|
31
|
-
kisa_utils-0.42.
|
|
32
|
-
kisa_utils-0.42.
|
|
33
|
-
kisa_utils-0.42.
|
|
30
|
+
kisa_utils-0.42.12.dist-info/METADATA,sha256=ZA1hRrzFvMwXN2KNJEy83HqiLdnkIvj8dHSUn6FDkX0,478
|
|
31
|
+
kisa_utils-0.42.12.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
32
|
+
kisa_utils-0.42.12.dist-info/top_level.txt,sha256=GFOLXZYqpBG9xtscGa2uGJAEiZ5NwsqHBH9NylnB29M,11
|
|
33
|
+
kisa_utils-0.42.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|