kisa-utils 0.40.0__py3-none-any.whl → 0.41.0__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/__init__.py +4 -2
- kisa_utils/cache.py +2 -2
- kisa_utils/queues/__init__.py +0 -0
- kisa_utils/queues/callables/__init__.py +4 -0
- kisa_utils/{queues.py → queues/callables/executorQueues.py} +17 -17
- {kisa_utils-0.40.0.dist-info → kisa_utils-0.41.0.dist-info}/METADATA +1 -1
- {kisa_utils-0.40.0.dist-info → kisa_utils-0.41.0.dist-info}/RECORD +10 -8
- kisa_utils-0.41.0.dist-info/top_level.txt +1 -0
- kisa_utils-0.40.0.dist-info/top_level.txt +0 -4
- /kisa_utils/{enqueue.py → queues/callables/enqueueFunctionCalls.py} +0 -0
- {kisa_utils-0.40.0.dist-info → kisa_utils-0.41.0.dist-info}/WHEEL +0 -0
kisa_utils/__init__.py
CHANGED
|
@@ -11,11 +11,13 @@ from kisa_utils import codes
|
|
|
11
11
|
from kisa_utils import log
|
|
12
12
|
from kisa_utils import token
|
|
13
13
|
from kisa_utils import threads
|
|
14
|
-
from kisa_utils import
|
|
14
|
+
from kisa_utils.queues.callables import executorQueues
|
|
15
15
|
from kisa_utils import cache
|
|
16
16
|
from kisa_utils import response
|
|
17
17
|
from kisa_utils import permissions
|
|
18
18
|
from kisa_utils import functionUtils
|
|
19
19
|
from kisa_utils import servers
|
|
20
|
-
from kisa_utils import enqueue
|
|
21
20
|
from kisa_utils import dataStructures
|
|
21
|
+
|
|
22
|
+
from kisa_utils import queues
|
|
23
|
+
from kisa_utils.queues.callables import enqueueFunctionCalls
|
kisa_utils/cache.py
CHANGED
|
@@ -6,7 +6,7 @@ this module is reponsible to creating and managing named caches for KISA
|
|
|
6
6
|
|
|
7
7
|
import time
|
|
8
8
|
from . import threads
|
|
9
|
-
from . import
|
|
9
|
+
from .queues.callables import executorQueues
|
|
10
10
|
from . import db
|
|
11
11
|
from typing import Callable
|
|
12
12
|
|
|
@@ -43,7 +43,7 @@ class Cache:
|
|
|
43
43
|
if not loopThreadReply['status']:
|
|
44
44
|
raise CacheException(f'cache main thread: {loopThreadReply["log"]}')
|
|
45
45
|
|
|
46
|
-
queueReply =
|
|
46
|
+
queueReply = executorQueues.create(f'_cache:{name}', self.__readQueue)
|
|
47
47
|
if not queueReply['status']:
|
|
48
48
|
raise CacheException(f'cache queue thread: {queueReply["log"]}')
|
|
49
49
|
|
|
File without changes
|
|
@@ -5,14 +5,14 @@ this module is reponsible to creating and managing named queues for KISA
|
|
|
5
5
|
'''
|
|
6
6
|
|
|
7
7
|
from queue import Queue as pyQueue
|
|
8
|
-
from
|
|
9
|
-
from
|
|
8
|
+
from ...structures import validator as structureValidator
|
|
9
|
+
from ... import threads
|
|
10
10
|
from typing import Callable, Any
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class ExecutorQueueException(Exception):
|
|
13
13
|
pass
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class ExecutorQueue:
|
|
16
16
|
__ACTIVE_QUEUES = {}
|
|
17
17
|
|
|
18
18
|
def __init__(self, name:str, executor:Callable, inputDefinitions:dict={}) -> None:
|
|
@@ -39,25 +39,25 @@ class Queue:
|
|
|
39
39
|
inputDefinitions['kwargs'] = inputDefinitions.get('kwargs',{})
|
|
40
40
|
|
|
41
41
|
if name in activeQueues:
|
|
42
|
-
raise
|
|
42
|
+
raise ExecutorQueueException(f'a queue already named `{name}` exists')
|
|
43
43
|
|
|
44
44
|
if not callable(executor):
|
|
45
|
-
raise
|
|
45
|
+
raise ExecutorQueueException('given `executor` is not a function/callable')
|
|
46
46
|
|
|
47
47
|
executorName = executor.__name__
|
|
48
48
|
if executorName.startswith('<'):
|
|
49
|
-
raise
|
|
49
|
+
raise ExecutorQueueException('lambda functions are not allowed')
|
|
50
50
|
|
|
51
51
|
if not (
|
|
52
52
|
isinstance(inputDefinitions, dict) and \
|
|
53
53
|
('args' in inputDefinitions) and isinstance(inputDefinitions['args'],(tuple,list)) and\
|
|
54
54
|
('kwargs' in inputDefinitions) and isinstance(inputDefinitions['kwargs'],dict) \
|
|
55
55
|
):
|
|
56
|
-
raise
|
|
56
|
+
raise ExecutorQueueException('invalid `inputDefinitions` given')
|
|
57
57
|
|
|
58
58
|
for kwarg in inputDefinitions['kwargs']:
|
|
59
59
|
if not isinstance(kwarg,str):
|
|
60
|
-
raise
|
|
60
|
+
raise ExecutorQueueException('all keys in inputDefinitions->kwargs must be strings')
|
|
61
61
|
|
|
62
62
|
self.executor = executor
|
|
63
63
|
self.inputDefinitions = inputDefinitions
|
|
@@ -112,7 +112,7 @@ def nameIsRegistered(name:str) -> bool:
|
|
|
112
112
|
Args:
|
|
113
113
|
name(str): the queue name
|
|
114
114
|
'''
|
|
115
|
-
return name in
|
|
115
|
+
return name in ExecutorQueue._Queue__ACTIVE_QUEUES
|
|
116
116
|
|
|
117
117
|
def create(name:str, executor:Callable, inputDefinitions:dict={}) -> dict:
|
|
118
118
|
'''
|
|
@@ -148,16 +148,16 @@ def create(name:str, executor:Callable, inputDefinitions:dict={}) -> dict:
|
|
|
148
148
|
inputDefinitions['kwargs'] = inputDefinitions.get('kwargs',None) or {}
|
|
149
149
|
|
|
150
150
|
if nameIsRegistered(name):
|
|
151
|
-
if inputDefinitions!=
|
|
151
|
+
if inputDefinitions!=ExecutorQueue._Queue__ACTIVE_QUEUES[name].inputDefinitions:
|
|
152
152
|
reply['log'] = f'a queue with the name `{name}` already exisits and has different inputDefinitions'
|
|
153
153
|
else:
|
|
154
154
|
reply['status'] = True
|
|
155
|
-
reply['queue'] =
|
|
155
|
+
reply['queue'] = ExecutorQueue._Queue__ACTIVE_QUEUES[name]
|
|
156
156
|
|
|
157
157
|
return reply
|
|
158
158
|
|
|
159
159
|
try:
|
|
160
|
-
queue =
|
|
160
|
+
queue = ExecutorQueue(name, executor, inputDefinitions)
|
|
161
161
|
except Exception as e:
|
|
162
162
|
reply['log'] = f'{e}'
|
|
163
163
|
return reply
|
|
@@ -181,7 +181,7 @@ def push(name:str, *args:tuple, **kwargs:dict) -> dict:
|
|
|
181
181
|
'''
|
|
182
182
|
reply = {'status':False, 'log':''}
|
|
183
183
|
|
|
184
|
-
queue =
|
|
184
|
+
queue = ExecutorQueue._Queue__ACTIVE_QUEUES.get(name,None)
|
|
185
185
|
|
|
186
186
|
if not queue:
|
|
187
187
|
reply['log'] = f'could not find queue named `{name}`'
|
|
@@ -189,13 +189,13 @@ def push(name:str, *args:tuple, **kwargs:dict) -> dict:
|
|
|
189
189
|
|
|
190
190
|
return queue.push(*args, **kwargs)
|
|
191
191
|
|
|
192
|
-
def get(name:str) ->
|
|
192
|
+
def get(name:str) -> ExecutorQueue | None:
|
|
193
193
|
'''
|
|
194
194
|
get queue instance using its name
|
|
195
195
|
Args:
|
|
196
196
|
name(str): the queue name
|
|
197
197
|
'''
|
|
198
|
-
return
|
|
198
|
+
return ExecutorQueue._Queue__ACTIVE_QUEUES.get(name,None)
|
|
199
199
|
|
|
200
200
|
if __name__=='__main__':
|
|
201
201
|
def addNumbers(a:int,b:int):
|
|
@@ -204,7 +204,7 @@ if __name__=='__main__':
|
|
|
204
204
|
queueReply = create('testQueue',addNumbers,{'args':(int,int)})
|
|
205
205
|
print(queueReply)
|
|
206
206
|
# queue = queueReply['queue']
|
|
207
|
-
queue:
|
|
207
|
+
queue:ExecutorQueue = get('testQueue')
|
|
208
208
|
|
|
209
209
|
for i in range(15):
|
|
210
210
|
print(queue.push(i,10))
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
kisa_utils/__init__.py,sha256
|
|
2
|
-
kisa_utils/cache.py,sha256=
|
|
1
|
+
kisa_utils/__init__.py,sha256=-g5gBmI4gV840-Brg1V1aZ_R_r3n_csB-PlRRdUV_UQ,745
|
|
2
|
+
kisa_utils/cache.py,sha256=WOL3e0wvoyESXTtlbVnUg9TYUoLzg64sLP9J4b4ti9k,7377
|
|
3
3
|
kisa_utils/codes.py,sha256=PV_S53Skggf4XetOdYoIKtEmM8cpN5wZwUlxje70WZY,904
|
|
4
4
|
kisa_utils/config.py,sha256=NfluzGKTh66qfNtC-Ae0zNb1XzMTgU2Me9Vi82R9c1E,2285
|
|
5
5
|
kisa_utils/dataStructures.py,sha256=ZgLpttJ66jfpU1NWzLDD1Czqxzj6sWereffgTQWhlV8,2679
|
|
6
6
|
kisa_utils/dates.py,sha256=zxe4n0PdKReZjK5ZkvnCZtJ55lk5oqu9oS8VX_nLozw,13966
|
|
7
7
|
kisa_utils/db.py,sha256=oUpqpew3a1a69Ow1xSydfB1S_QhiUrCtba_7dbK0XBs,49715
|
|
8
8
|
kisa_utils/encryption.py,sha256=nFzNpzWV_D9uSEq4FsgCnlS7FQtqWP9fvM_81rsfcLo,4218
|
|
9
|
-
kisa_utils/enqueue.py,sha256=VIliaMvw4MUdOqts0dXdZCYNxs-QrOVjIRAR3scGrRM,11786
|
|
10
9
|
kisa_utils/figures.py,sha256=pYIpQzu1OXRSsY1d98GhgPifnIRmgl-r7S32ai-Ms0c,3731
|
|
11
10
|
kisa_utils/functionUtils.py,sha256=PlXjnmU1uJWNdISlJJ3SCgavTsgNBoebaa9dtWSFhRA,6553
|
|
12
11
|
kisa_utils/log.py,sha256=0TYdxcIBts026RCSuVIQBcZ-CW1ES7n3M1nEIjmeLTM,2295
|
|
13
|
-
kisa_utils/queues.py,sha256=9QqPtDujw6tbWk7uUiXrsd0rVBTIkzeQw9b45l5Fo3k,6502
|
|
14
12
|
kisa_utils/remote.py,sha256=0RDrfC4RUW4m6JLziC0_EXJYqzWp38Rw8NDroJ0MuqI,2149
|
|
15
13
|
kisa_utils/response.py,sha256=asETUBkeF5OlSTwa-coa7lZDCKmQlHCmHf6eaZFl8CU,4560
|
|
16
14
|
kisa_utils/standardize.py,sha256=nt-uzHQFoKxGscD_MpDYXw65Teg3724whAqa6Kh_zhE,2231
|
|
@@ -19,12 +17,16 @@ kisa_utils/threads.py,sha256=qQqsf64YHMyLpboq5AEXKxYqf3iXUhxiJe6Ymg-vlxI,12840
|
|
|
19
17
|
kisa_utils/token.py,sha256=Y2qglWYWpmHxoXBh-TH0r1as0uPV5LLqMNcunLvM4vM,7850
|
|
20
18
|
kisa_utils/permissions/__config__.py,sha256=i3ELkOydDnjKx2ozQTxLZdZ8DXSeUncnl2kRxANjFmM,613
|
|
21
19
|
kisa_utils/permissions/__init__.py,sha256=q7LGl26f-MPXkLS6nxBKDotW3xdB8y7pI5S_Oo5fPOw,47976
|
|
20
|
+
kisa_utils/queues/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
+
kisa_utils/queues/callables/__init__.py,sha256=OJL3AQnaAS1Eek4H6WBH3WefA2wf-x03cwFmRSK8hoU,141
|
|
22
|
+
kisa_utils/queues/callables/enqueueFunctionCalls.py,sha256=VIliaMvw4MUdOqts0dXdZCYNxs-QrOVjIRAR3scGrRM,11786
|
|
23
|
+
kisa_utils/queues/callables/executorQueues.py,sha256=x6bAqxBSZRZ_kL8CK1lSN6JYAYFLxzM84LC1RmwaOLw,6626
|
|
22
24
|
kisa_utils/servers/__init__.py,sha256=lPqDyGTrFo0qwPZ2WA9Xtcpc5D8AIU4huqgFx1iZf68,19
|
|
23
25
|
kisa_utils/servers/flask.py,sha256=XZYY1pWnP1mSvaS5Uv8G3EFJV5BJBQtU2gDbO8suvLc,40422
|
|
24
26
|
kisa_utils/structures/__init__.py,sha256=JBU1j3A42jQ62ALKnsS1Hav9YXcYwjDw1wQJtohXPbU,83
|
|
25
27
|
kisa_utils/structures/utils.py,sha256=665rXIapGwFqejizeJwy3DryeskCQOdgP25BCdLkGvk,2898
|
|
26
28
|
kisa_utils/structures/validator.py,sha256=JhD9jcfbjTwBr_7OfuNaJd_cYr7wR2emFhsCEo5MCHQ,4323
|
|
27
|
-
kisa_utils-0.
|
|
28
|
-
kisa_utils-0.
|
|
29
|
-
kisa_utils-0.
|
|
30
|
-
kisa_utils-0.
|
|
29
|
+
kisa_utils-0.41.0.dist-info/METADATA,sha256=rtGcPNxF8RSBW5avDpByGXLIuquskvSJ0n9Ij84-EqM,477
|
|
30
|
+
kisa_utils-0.41.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
31
|
+
kisa_utils-0.41.0.dist-info/top_level.txt,sha256=GFOLXZYqpBG9xtscGa2uGJAEiZ5NwsqHBH9NylnB29M,11
|
|
32
|
+
kisa_utils-0.41.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
kisa_utils
|
|
File without changes
|
|
File without changes
|