funboost 43.8__py3-none-any.whl → 43.9__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 funboost might be problematic. Click here for more details.
- funboost/__init__.py +1 -1
- funboost/consumers/base_consumer.py +39 -10
- funboost/core/func_params_model.py +12 -1
- funboost/core/helper_funs.py +5 -1
- funboost/publishers/base_publisher.py +3 -2
- {funboost-43.8.dist-info → funboost-43.9.dist-info}/METADATA +1 -1
- {funboost-43.8.dist-info → funboost-43.9.dist-info}/RECORD +11 -11
- {funboost-43.8.dist-info → funboost-43.9.dist-info}/LICENSE +0 -0
- {funboost-43.8.dist-info → funboost-43.9.dist-info}/WHEEL +0 -0
- {funboost-43.8.dist-info → funboost-43.9.dist-info}/entry_points.txt +0 -0
- {funboost-43.8.dist-info → funboost-43.9.dist-info}/top_level.txt +0 -0
funboost/__init__.py
CHANGED
|
@@ -33,7 +33,7 @@ import nb_log
|
|
|
33
33
|
from funboost.core.current_task import funboost_current_task, get_current_taskid
|
|
34
34
|
from funboost.core.loggers import develop_logger
|
|
35
35
|
|
|
36
|
-
from funboost.core.func_params_model import BoosterParams, PublisherParams
|
|
36
|
+
from funboost.core.func_params_model import BoosterParams, PublisherParams, BaseJsonAbleModel
|
|
37
37
|
from funboost.core.task_id_logger import TaskIdLogger
|
|
38
38
|
from nb_log import (get_logger, LoggerLevelSetterMixin, LogManager, CompatibleLogger,
|
|
39
39
|
LoggerMixinDefaultWithFileHandler, stdout_write, is_main_process,
|
|
@@ -49,7 +49,7 @@ from funboost.concurrent_pool.single_thread_executor import SoloExecutor
|
|
|
49
49
|
|
|
50
50
|
from funboost.core.function_result_status_saver import ResultPersistenceHelper, FunctionResultStatus, RunStatus
|
|
51
51
|
|
|
52
|
-
from funboost.core.helper_funs import delete_keys_and_return_new_dict, get_publish_time
|
|
52
|
+
from funboost.core.helper_funs import delete_keys_and_return_new_dict, get_publish_time, generate_task_id
|
|
53
53
|
|
|
54
54
|
from funboost.concurrent_pool.async_helper import simple_run_in_executor
|
|
55
55
|
from funboost.concurrent_pool.async_pool_executor import AsyncPoolExecutor
|
|
@@ -215,13 +215,15 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
215
215
|
self._consuming_function_is_asyncio = inspect.iscoroutinefunction(self.consuming_function)
|
|
216
216
|
self.custom_init()
|
|
217
217
|
# develop_logger.warning(consumer_params._log_filename)
|
|
218
|
-
self.publisher_params = PublisherParams(queue_name=consumer_params.queue_name, consuming_function=consumer_params.consuming_function,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
# self.publisher_params = PublisherParams(queue_name=consumer_params.queue_name, consuming_function=consumer_params.consuming_function,
|
|
219
|
+
# broker_kind=self.BROKER_KIND, log_level=consumer_params.log_level,
|
|
220
|
+
# logger_prefix=consumer_params.logger_prefix,
|
|
221
|
+
# create_logger_file=consumer_params.create_logger_file,
|
|
222
|
+
# log_filename=consumer_params.log_filename,
|
|
223
|
+
# logger_name=consumer_params.logger_name,
|
|
224
|
+
# broker_exclusive_config=self.consumer_params.broker_exclusive_config)
|
|
225
|
+
self.publisher_params = BaseJsonAbleModel.init_by_another_model(PublisherParams, consumer_params)
|
|
226
|
+
# print(self.publisher_params)
|
|
225
227
|
if is_main_process:
|
|
226
228
|
self.logger.info(f'{self.queue_name} consumer 的消费者配置:\n {self.consumer_params.json_str_value()}')
|
|
227
229
|
atexit.register(self.join_shedual_task_thread)
|
|
@@ -381,6 +383,33 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
381
383
|
"""
|
|
382
384
|
raise NotImplementedError
|
|
383
385
|
|
|
386
|
+
def __auto_fill_msg(self, msg: dict):
|
|
387
|
+
"""填充消息,消息没有使用funboost来发送,并且没有extra相关字段时候"""
|
|
388
|
+
""" 一般消息至少包含这样
|
|
389
|
+
{
|
|
390
|
+
"a": 42,
|
|
391
|
+
"b": 84,
|
|
392
|
+
"extra": {
|
|
393
|
+
"task_id": "queue_2_result:9b79a372-f765-4a33-8639-9d15d7a95f61",
|
|
394
|
+
"publish_time": 1701687443.3596,
|
|
395
|
+
"publish_time_format": "2023-12-04 18:57:23"
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
"""
|
|
399
|
+
"""
|
|
400
|
+
extra_params = {'task_id': task_id, 'publish_time': round(time.time(), 4),
|
|
401
|
+
'publish_time_format': time.strftime('%Y-%m-%d %H:%M:%S')}
|
|
402
|
+
"""
|
|
403
|
+
if 'extra' not in msg:
|
|
404
|
+
msg['extra'] = {}
|
|
405
|
+
extra = msg['extra']
|
|
406
|
+
if 'task_id' not in extra:
|
|
407
|
+
extra['task_id'] = generate_task_id(self._queue_name)
|
|
408
|
+
if 'publish_time' not in extra:
|
|
409
|
+
extra['publish_time'] = round(time.time(), 4)
|
|
410
|
+
if 'publish_time_format':
|
|
411
|
+
extra['publish_time_format'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
|
412
|
+
|
|
384
413
|
def _submit_task(self, kw):
|
|
385
414
|
while 1: # 这一块的代码为支持暂停消费。
|
|
386
415
|
# print(self._pause_flag)
|
|
@@ -396,7 +425,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
396
425
|
self._requeue(kw)
|
|
397
426
|
time.sleep(self.time_interval_for_check_do_not_run_time)
|
|
398
427
|
return
|
|
399
|
-
|
|
428
|
+
self.__auto_fill_msg(kw['body'])
|
|
400
429
|
function_only_params = delete_keys_and_return_new_dict(kw['body'], )
|
|
401
430
|
if self._get_priority_conf(kw, 'do_task_filtering') and self._redis_filter.check_value_exists(
|
|
402
431
|
function_only_params): # 对函数的参数进行检查,过滤已经执行过并且成功的任务。
|
|
@@ -81,6 +81,14 @@ class BaseJsonAbleModel(BaseModel):
|
|
|
81
81
|
# allow_mutation = False
|
|
82
82
|
extra = "forbid"
|
|
83
83
|
|
|
84
|
+
@staticmethod
|
|
85
|
+
def init_by_another_model(model_type: typing.Type[BaseModel], modelx: BaseModel):
|
|
86
|
+
init_dict = {}
|
|
87
|
+
for k, v in modelx.dict().items():
|
|
88
|
+
if k in model_type.__fields__.keys():
|
|
89
|
+
init_dict[k] = v
|
|
90
|
+
return model_type(**init_dict)
|
|
91
|
+
|
|
84
92
|
|
|
85
93
|
class FunctionResultStatusPersistanceConfig(BaseJsonAbleModel):
|
|
86
94
|
is_save_status: bool # 是否保存函数的运行状态信息
|
|
@@ -175,6 +183,8 @@ class BoosterParams(BaseJsonAbleModel):
|
|
|
175
183
|
broker_exclusive_config: dict = {} # 加上一个不同种类中间件非通用的配置,不同中间件自身独有的配置,不是所有中间件都兼容的配置,因为框架支持30种消息队列,消息队列不仅仅是一般的先进先出queue这么简单的概念,
|
|
176
184
|
# 例如kafka支持消费者组,rabbitmq也支持各种独特概念例如各种ack机制 复杂路由机制,有的中间件原生能支持消息优先级有的中间件不支持,每一种消息队列都有独特的配置参数意义,可以通过这里传递。每种中间件能传递的键值对可以看consumer类的 BROKER_EXCLUSIVE_CONFIG_DEFAULT
|
|
177
185
|
|
|
186
|
+
should_check_publish_func_params: bool = True # 消息发布时候是否校验消息发布内容,比如有的人发布消息,函数只接受a,b两个入参,他去传2个入参,或者传参不存在的参数名字, 如果消费函数你非要写*args,**kwargs,那就需要关掉发布消息时候的函数入参检查
|
|
187
|
+
|
|
178
188
|
auto_generate_info: dict = {} # 自动生成的信息,不需要用户主动传参.
|
|
179
189
|
|
|
180
190
|
@root_validator(skip_on_failure=True)
|
|
@@ -194,7 +204,7 @@ class BoosterParams(BaseJsonAbleModel):
|
|
|
194
204
|
# if not set(values.keys()).issubset(set(BoosterParams.__fields__.keys())):
|
|
195
205
|
# raise ValueError(f'{cls.__name__} 的字段包含了父类 BoosterParams 不存在的字段')
|
|
196
206
|
for k in values.keys():
|
|
197
|
-
if k not in BoosterParams.
|
|
207
|
+
if k not in BoosterParams.__fields__.keys():
|
|
198
208
|
raise ValueError(f'{cls.__name__} 的字段新增了父类 BoosterParams 不存在的字段 "{k}"') # 使 BoosterParams的子类,不能增加字段,只能覆盖字段.
|
|
199
209
|
return values
|
|
200
210
|
|
|
@@ -255,6 +265,7 @@ class PublisherParams(BaseJsonAbleModel):
|
|
|
255
265
|
consuming_function: typing.Callable = None # consuming_function 作用是 inspect 模块获取函数的入参信息
|
|
256
266
|
broker_kind: str = None
|
|
257
267
|
broker_exclusive_config: dict = {}
|
|
268
|
+
should_check_publish_func_params: bool = True # 消息发布时候是否校验消息发布内容,比如有的人发布消息,函数只接受a,b两个入参,他去传2个入参,或者传参不存在的参数名字, 如果消费函数你非要写*args,**kwargs,那就需要关掉发布消息时候的函数入参检查
|
|
258
269
|
|
|
259
270
|
|
|
260
271
|
if __name__ == '__main__':
|
funboost/core/helper_funs.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import copy
|
|
2
2
|
import time
|
|
3
|
+
import uuid
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def get_publish_time(paramsx: dict):
|
|
@@ -42,4 +43,7 @@ def _try_get_user_funboost_common_config(funboost_common_conf_field:str):
|
|
|
42
43
|
return getattr(funboost_config.FunboostCommonConfig,funboost_common_conf_field)
|
|
43
44
|
except Exception as e:
|
|
44
45
|
print(e)
|
|
45
|
-
return None
|
|
46
|
+
return None
|
|
47
|
+
|
|
48
|
+
def generate_task_id(queue_name:str):
|
|
49
|
+
return f'{queue_name}_result:{uuid.uuid4()}'
|
|
@@ -19,6 +19,7 @@ import amqpstorm
|
|
|
19
19
|
|
|
20
20
|
import nb_log
|
|
21
21
|
from funboost.core.func_params_model import PublisherParams, PriorityConsumingControlConfig
|
|
22
|
+
from funboost.core.helper_funs import generate_task_id
|
|
22
23
|
from funboost.core.loggers import develop_logger
|
|
23
24
|
|
|
24
25
|
from pikav1.exceptions import AMQPError as PikaAMQPError
|
|
@@ -188,9 +189,9 @@ class AbstractPublisher(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
188
189
|
if 'extra' in msg:
|
|
189
190
|
msg_function_kw.pop('extra')
|
|
190
191
|
raw_extra = msg['extra']
|
|
191
|
-
if self.publish_params_checker:
|
|
192
|
+
if self.publish_params_checker and self.publisher_params.should_check_publish_func_params:
|
|
192
193
|
self.publish_params_checker.check_params(msg_function_kw)
|
|
193
|
-
task_id = task_id or
|
|
194
|
+
task_id = task_id or generate_task_id(self._queue_name)
|
|
194
195
|
extra_params = {'task_id': task_id, 'publish_time': round(time.time(), 4),
|
|
195
196
|
'publish_time_format': time.strftime('%Y-%m-%d %H:%M:%S')}
|
|
196
197
|
if priority_control_config:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: funboost
|
|
3
|
-
Version: 43.
|
|
3
|
+
Version: 43.9
|
|
4
4
|
Summary: pip install funboost,python全功能分布式函数调度框架,。支持python所有类型的并发模式和一切知名消息队列中间件,支持如 celery dramatiq等框架整体作为funboost中间件,python函数加速器,框架包罗万象,用户能想到的控制功能全都有。一统编程思维,兼容50% python业务场景,适用范围广。只需要一行代码即可分布式执行python一切函数,99%用过funboost的pythoner 感受是 简易 方便 强劲 强大,相见恨晚
|
|
5
5
|
Home-page: https://github.com/ydf0509/funboost
|
|
6
6
|
Author: bfzs
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
funboost/__init__.py,sha256=
|
|
1
|
+
funboost/__init__.py,sha256=H-RYbw9IE6_YoCnuABJoytt_IAGKkpt-IFzEY8GtSHo,3832
|
|
2
2
|
funboost/__init__old.py,sha256=07A1MLsxLtuRQQOIfDyphddOwNBrGe34enoHWAnjV14,20379
|
|
3
3
|
funboost/__main__.py,sha256=-6Nogi666Y0LN8fVm3JmHGTOk8xEGWvotW_GDbSaZME,1065
|
|
4
4
|
funboost/constant.py,sha256=Yxt3WJt9D8ybcrgiojOy0qjnq5mffwTnTJplerGL0Oo,7188
|
|
@@ -33,7 +33,7 @@ funboost/concurrent_pool/backup/async_pool_executor0223.py,sha256=RVUZiylUvpTm6U
|
|
|
33
33
|
funboost/concurrent_pool/backup/async_pool_executor_back.py,sha256=KL6zEQaa1KkZOlAO85mCC1gwLm-YC5Ghn21IUom0UKM,9598
|
|
34
34
|
funboost/concurrent_pool/backup/async_pool_executor_janus.py,sha256=OHMWJ9l3EYTpPpcrPrGGKd4K0tmQ2PN8HiX0Dta0EOo,5728
|
|
35
35
|
funboost/consumers/__init__.py,sha256=ZXY_6Kut1VYNQiF5aWEgIWobsW1ht9YUP0TdRZRWFqI,126
|
|
36
|
-
funboost/consumers/base_consumer.py,sha256=
|
|
36
|
+
funboost/consumers/base_consumer.py,sha256=rUxBGuvadSBxNRw2uoZpC9plMUxwQBWgjQqAf4Wo1mU,75738
|
|
37
37
|
funboost/consumers/celery_consumer.py,sha256=9gtz7nlZkmv3ErmaseT0_Q__ltSPx-fOcwi-TMPoaLA,9220
|
|
38
38
|
funboost/consumers/confirm_mixin.py,sha256=eY6fNwx51Hn4bQSYRjyTRwOqfCGsikVnd2Ga_Ep31N4,6062
|
|
39
39
|
funboost/consumers/dramatiq_consumer.py,sha256=ozmeAfeF0U-YNYHK4suQB0N264h5AZdfMH0O45Mh-8A,2229
|
|
@@ -85,10 +85,10 @@ funboost/core/booster.py,sha256=BMSrQbpvIfhigzHjloFwHb7mlw69bvk48RJN43dDiTQ,1591
|
|
|
85
85
|
funboost/core/current_task.py,sha256=rAIQVLqYqtlHVRkjl17yki-mqvuMb640ssGmto4RSdA,4864
|
|
86
86
|
funboost/core/exceptions.py,sha256=pLF7BkRJAfDiWp2_xGZqencmwdPiSQI1NENbImExknY,1311
|
|
87
87
|
funboost/core/fabric_deploy_helper.py,sha256=AbiQqCCDCnCf9vU4rhaAGLRiS4XBe5_WMnoHmAysYto,9958
|
|
88
|
-
funboost/core/func_params_model.py,sha256=
|
|
88
|
+
funboost/core/func_params_model.py,sha256=9LbfO0HnRmTph0qy8BDvBtoYurGXPfnX6hAiUzPM4ZI,19115
|
|
89
89
|
funboost/core/function_result_status_config.py,sha256=PyjqAQOiwsLt28sRtH-eYRjiI3edPFO4Nde0ILFRReE,1764
|
|
90
90
|
funboost/core/function_result_status_saver.py,sha256=UdokGSwU630t70AZnT9Ecj7GpYXORBDivlc9kadoI2E,9172
|
|
91
|
-
funboost/core/helper_funs.py,sha256=
|
|
91
|
+
funboost/core/helper_funs.py,sha256=k5HttGoz-E9doLBFz0P0b8SCiCWXuk3ZYD_A-tAfn0Q,1682
|
|
92
92
|
funboost/core/kill_remote_task.py,sha256=MZ5vWLGt6SxyN76h5Lf_id9tyVUzjR-qXNyJwXaGlZY,8129
|
|
93
93
|
funboost/core/lazy_impoter.py,sha256=k0qZs39VL5qb7FspMt0x1noxqh3RIzt_czlFBwcyvKA,2722
|
|
94
94
|
funboost/core/loggers.py,sha256=173aXdqE8nAe8t6OcVMNAFsCUClVrWQovdQhTAg9IyM,2407
|
|
@@ -122,7 +122,7 @@ funboost/function_result_web/static/js/jquery-1.11.0.min.js,sha256=ryQZ3RXgnqkTz
|
|
|
122
122
|
funboost/function_result_web/templates/index.html,sha256=YM0582Q4t2da-xBf3Ga0McIfcsT9H98rjZck-irMkGo,20387
|
|
123
123
|
funboost/function_result_web/templates/login.html,sha256=q37dj7O0LeyiV38Zd5P1Qn_qmhjdFomuYTRY1Yk48Bo,2007
|
|
124
124
|
funboost/publishers/__init__.py,sha256=xqBHlvsJQVPfbdvP84G0LHmVB7-pFBS7vDnX1Uo9pVY,131
|
|
125
|
-
funboost/publishers/base_publisher.py,sha256=
|
|
125
|
+
funboost/publishers/base_publisher.py,sha256=81Lj8atdD9_Hyh4cGJCa84zhxKQzqV13x2bax58fQwc,15176
|
|
126
126
|
funboost/publishers/celery_publisher.py,sha256=uc9N1uLW74skUCw8dsnvxORM2O3cy4SiI7tUZRmvkHA,2336
|
|
127
127
|
funboost/publishers/celery_publisher000.py,sha256=2XLOyU2__vlIUTi5L15uf0BJqAIjxbc3kCLIRDSOY9w,3966
|
|
128
128
|
funboost/publishers/confluent_kafka_publisher.py,sha256=gC4SUk6I_7zjSngcbTI7oTJ7sza3oE3PE19KQkwCpn4,4802
|
|
@@ -264,9 +264,9 @@ funboost/utils/pysnooper_ydf/utils.py,sha256=evSmGi_Oul7vSP47AJ0DLjFwoCYCfunJZ1m
|
|
|
264
264
|
funboost/utils/pysnooper_ydf/variables.py,sha256=QejRDESBA06KG9OH4sBT4J1M55eaU29EIHg8K_igaXo,3693
|
|
265
265
|
funboost/utils/times/__init__.py,sha256=Y4bQD3SIA_E7W2YvHq2Qdi0dGM4H2DxyFNdDOuFOq1w,2417
|
|
266
266
|
funboost/utils/times/version.py,sha256=11XfnZVVzOgIhXXdeN_mYfdXThfrsbQHpA0wCjz-hpg,17
|
|
267
|
-
funboost-43.
|
|
268
|
-
funboost-43.
|
|
269
|
-
funboost-43.
|
|
270
|
-
funboost-43.
|
|
271
|
-
funboost-43.
|
|
272
|
-
funboost-43.
|
|
267
|
+
funboost-43.9.dist-info/LICENSE,sha256=9EPP2ktG_lAPB8PjmWV-c9BiaJHc_FP6pPLcUrUwx0E,11562
|
|
268
|
+
funboost-43.9.dist-info/METADATA,sha256=7fO2oWHqPhj3WOk1X00OvefH5GGGx8Rsx2n7wYPEzWI,30408
|
|
269
|
+
funboost-43.9.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
270
|
+
funboost-43.9.dist-info/entry_points.txt,sha256=yMSSAGRzRAAhGyNNQHw24MooKlDZsaJ499_D6fPl58A,96
|
|
271
|
+
funboost-43.9.dist-info/top_level.txt,sha256=K8WuKnS6MRcEWxP1NvbmCeujJq6TEfbsB150YROlRw0,9
|
|
272
|
+
funboost-43.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|