funboost 46.9__py3-none-any.whl → 47.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.
Potentially problematic release.
This version of funboost might be problematic. Click here for more details.
- funboost/__init__.py +1 -1
- funboost/core/funboost_time.py +1 -0
- funboost/core/func_params_model.py +14 -3
- funboost/publishers/base_publisher.py +8 -9
- {funboost-46.9.dist-info → funboost-47.0.dist-info}/METADATA +1 -1
- {funboost-46.9.dist-info → funboost-47.0.dist-info}/RECORD +10 -10
- {funboost-46.9.dist-info → funboost-47.0.dist-info}/LICENSE +0 -0
- {funboost-46.9.dist-info → funboost-47.0.dist-info}/WHEEL +0 -0
- {funboost-46.9.dist-info → funboost-47.0.dist-info}/entry_points.txt +0 -0
- {funboost-46.9.dist-info → funboost-47.0.dist-info}/top_level.txt +0 -0
funboost/__init__.py
CHANGED
funboost/core/funboost_time.py
CHANGED
|
@@ -10,6 +10,7 @@ from funboost.funboost_config_deafult import FunboostCommonConfig
|
|
|
10
10
|
|
|
11
11
|
class FunboostTime(NbTime):
|
|
12
12
|
default_formatter = NbTime.FORMATTER_DATETIME_NO_ZONE
|
|
13
|
+
|
|
13
14
|
def get_time_zone_str(self,time_zone: typing.Union[str, datetime.tzinfo,None] = None):
|
|
14
15
|
return time_zone or self.default_time_zone or FunboostCommonConfig.TIMEZONE or self.get_localzone_name()
|
|
15
16
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
1
3
|
import asyncio
|
|
2
4
|
import datetime
|
|
3
5
|
import functools
|
|
4
6
|
import json
|
|
5
7
|
import logging
|
|
6
8
|
import typing
|
|
9
|
+
from pydantic.main import IncEx
|
|
7
10
|
from typing_extensions import Literal
|
|
8
11
|
from collections import OrderedDict
|
|
9
12
|
|
|
@@ -152,7 +155,7 @@ class BoosterParams(BaseJsonAbleModel):
|
|
|
152
155
|
is_push_to_dlx_queue_when_retry_max_times: bool = False # 函数达到最大重试次数仍然没成功,是否发送到死信队列,死信队列的名字是 队列名字 + _dlx。
|
|
153
156
|
|
|
154
157
|
consumin_function_decorator: typing.Callable = None # 函数的装饰器。因为此框架做参数自动转指点,需要获取精准的入参名称,不支持在消费函数上叠加 @ *args **kwargs的装饰器,如果想用装饰器可以这里指定。
|
|
155
|
-
function_timeout: typing.Union[int, float] =
|
|
158
|
+
function_timeout: typing.Union[int, float,None] = None # 超时秒数,函数运行超过这个时间,则自动杀死函数。为0是不限制。 谨慎使用,非必要别去设置超时时间,设置后性能会降低(因为需要把用户函数包装到另一个线单独的程中去运行),而且突然强制超时杀死运行中函数,可能会造成死锁.(例如用户函数在获得线程锁后突然杀死函数,别的线程再也无法获得锁了)
|
|
156
159
|
|
|
157
160
|
log_level: int = logging.DEBUG # 消费者和发布者的日志级别,建议设置DEBUG级别,不然无法知道正在运行什么消息
|
|
158
161
|
logger_prefix: str = '' # 日志名字前缀,可以设置前缀
|
|
@@ -195,6 +198,7 @@ class BoosterParams(BaseJsonAbleModel):
|
|
|
195
198
|
# 例如kafka支持消费者组,rabbitmq也支持各种独特概念例如各种ack机制 复杂路由机制,有的中间件原生能支持消息优先级有的中间件不支持,每一种消息队列都有独特的配置参数意义,可以通过这里传递。每种中间件能传递的键值对可以看consumer类的 BROKER_EXCLUSIVE_CONFIG_DEFAULT
|
|
196
199
|
|
|
197
200
|
should_check_publish_func_params: bool = True # 消息发布时候是否校验消息发布内容,比如有的人发布消息,函数只接受a,b两个入参,他去传2个入参,或者传参不存在的参数名字; 如果消费函数加了装饰器 ,你非要写*args,**kwargs,那就需要关掉发布消息时候的函数入参检查
|
|
201
|
+
publish_msg_log_use_full_msg: bool = False # 发布到消息队列的消息内容的日志,是否显示消息的完整体,还是只显示函数入参。
|
|
198
202
|
|
|
199
203
|
consumer_override_cls: typing.Optional[typing.Type] = None # 使用 consumer_override_cls 和 publisher_override_cls 来自定义重写或新增消费者 发布者,见文档4.21b介绍,
|
|
200
204
|
publisher_override_cls: typing.Optional[typing.Type] = None
|
|
@@ -272,7 +276,12 @@ class PriorityConsumingControlConfig(BaseJsonAbleModel):
|
|
|
272
276
|
例如消费为add函数,可以每个独立的任务设置不同的超时时间,不同的重试次数,是否使用rpc模式。这里的配置优先,可以覆盖生成消费者时候的配置。
|
|
273
277
|
"""
|
|
274
278
|
|
|
275
|
-
|
|
279
|
+
class Config:
|
|
280
|
+
json_encoders = {
|
|
281
|
+
datetime.datetime: lambda v: v.strftime("%Y-%m-%d %H:%M:%S")
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function_timeout: typing.Union[float, int,None] = None
|
|
276
285
|
|
|
277
286
|
max_retry_times: int = None
|
|
278
287
|
|
|
@@ -297,6 +306,8 @@ class PriorityConsumingControlConfig(BaseJsonAbleModel):
|
|
|
297
306
|
return values
|
|
298
307
|
|
|
299
308
|
|
|
309
|
+
|
|
310
|
+
|
|
300
311
|
class PublisherParams(BaseJsonAbleModel):
|
|
301
312
|
queue_name: str
|
|
302
313
|
log_level: int = logging.DEBUG
|
|
@@ -311,7 +322,7 @@ class PublisherParams(BaseJsonAbleModel):
|
|
|
311
322
|
should_check_publish_func_params: bool = True # 消息发布时候是否校验消息发布内容,比如有的人发布消息,函数只接受a,b两个入参,他去传2个入参,或者传参不存在的参数名字, 如果消费函数你非要写*args,**kwargs,那就需要关掉发布消息时候的函数入参检查
|
|
312
323
|
publisher_override_cls: typing.Optional[typing.Type] = None
|
|
313
324
|
# func_params_is_pydantic_model: bool = False # funboost 兼容支持 函数娼还是 pydantic model类型,funboost在发布之前和取出来时候自己转化。
|
|
314
|
-
|
|
325
|
+
publish_msg_log_use_full_msg: bool = False # 发布到消息队列的消息内容的日志,是否显示消息的完整体,还是只显示函数入参。
|
|
315
326
|
consuming_function_kind: typing.Optional[str] = None # 自动生成的信息,不需要用户主动传参.
|
|
316
327
|
|
|
317
328
|
|
|
@@ -17,15 +17,12 @@ import typing
|
|
|
17
17
|
from functools import wraps
|
|
18
18
|
from threading import Lock
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
import nb_log
|
|
22
21
|
from funboost.constant import ConstStrForClassMethod, FunctionKind
|
|
23
22
|
from funboost.core.func_params_model import PublisherParams, PriorityConsumingControlConfig
|
|
24
23
|
from funboost.core.helper_funs import MsgGenerater
|
|
25
24
|
from funboost.core.loggers import develop_logger
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
26
|
# from nb_log import LoggerLevelSetterMixin, LoggerMixin
|
|
30
27
|
from funboost.core.loggers import LoggerLevelSetterMixin, FunboostFileLoggerMixin, get_logger
|
|
31
28
|
from funboost.core.msg_result_getter import AsyncResult, AioAsyncResult
|
|
@@ -186,7 +183,7 @@ class AbstractPublisher(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
186
183
|
return msg_dict['extra'].get('other_extra_params', {}).get(k, None)
|
|
187
184
|
|
|
188
185
|
def _convert_msg(self, msg: typing.Union[str, dict], task_id=None,
|
|
189
|
-
priority_control_config: PriorityConsumingControlConfig = None) -> (typing.Dict, typing.Dict, typing.Dict,str):
|
|
186
|
+
priority_control_config: PriorityConsumingControlConfig = None) -> (typing.Dict, typing.Dict, typing.Dict, str):
|
|
190
187
|
msg = Serialization.to_dict(msg)
|
|
191
188
|
msg_function_kw = copy.deepcopy(msg)
|
|
192
189
|
raw_extra = {}
|
|
@@ -198,7 +195,7 @@ class AbstractPublisher(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
198
195
|
task_id = task_id or MsgGenerater.generate_task_id(self._queue_name)
|
|
199
196
|
extra_params = MsgGenerater.generate_pulish_time_and_task_id(self._queue_name, task_id=task_id)
|
|
200
197
|
if priority_control_config:
|
|
201
|
-
extra_params.update(priority_control_config.
|
|
198
|
+
extra_params.update(Serialization.to_dict(priority_control_config.json(exclude_none=True))) # priority_control_config.json 是为了充分使用 pydantic的自定义时间格式化字符串
|
|
202
199
|
extra_params.update(raw_extra)
|
|
203
200
|
msg['extra'] = extra_params
|
|
204
201
|
return msg, msg_function_kw, extra_params, task_id
|
|
@@ -215,10 +212,12 @@ class AbstractPublisher(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
215
212
|
msg = copy.deepcopy(msg) # 字典是可变对象,不要改变影响用户自身的传参字典. 用户可能继续使用这个传参字典.
|
|
216
213
|
msg, msg_function_kw, extra_params, task_id = self._convert_msg(msg, task_id, priority_control_config)
|
|
217
214
|
t_start = time.time()
|
|
215
|
+
msg_json = Serialization.to_json_str(msg)
|
|
218
216
|
decorators.handle_exception(retry_times=10, is_throw_error=True, time_sleep=0.1)(
|
|
219
|
-
self.concrete_realization_of_publish)(
|
|
217
|
+
self.concrete_realization_of_publish)(msg_json)
|
|
220
218
|
|
|
221
|
-
self.logger.debug(f'向{self._queue_name} 队列,推送消息 耗时{round(time.time() - t_start, 4)}秒 {msg_function_kw}',
|
|
219
|
+
self.logger.debug(f'向{self._queue_name} 队列,推送消息 耗时{round(time.time() - t_start, 4)}秒 {msg_json if self.publisher_params.publish_msg_log_use_full_msg else msg_function_kw}',
|
|
220
|
+
extra={'task_id': task_id}) # 显示msg太长了。
|
|
222
221
|
with self._lock_for_count:
|
|
223
222
|
self.count_per_minute += 1
|
|
224
223
|
self.publish_msg_num_total += 1
|
|
@@ -344,8 +343,8 @@ def deco_mq_conn_error(f):
|
|
|
344
343
|
except Exception as e:
|
|
345
344
|
import amqpstorm
|
|
346
345
|
from pikav1.exceptions import AMQPError as PikaAMQPError
|
|
347
|
-
if isinstance(e,(PikaAMQPError, amqpstorm.AMQPError)):
|
|
348
|
-
|
|
346
|
+
if isinstance(e, (PikaAMQPError, amqpstorm.AMQPError)):
|
|
347
|
+
# except (PikaAMQPError, amqpstorm.AMQPError,) as e: # except BaseException as e: # 现在装饰器用到了绝大多出地方,单个异常类型不行。ex
|
|
349
348
|
self.logger.error(f'中间件链接出错 ,方法 {f.__name__} 出错 ,{e}')
|
|
350
349
|
self.init_broker()
|
|
351
350
|
return f(self, *args, **kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: funboost
|
|
3
|
-
Version:
|
|
3
|
+
Version: 47.0
|
|
4
4
|
Summary: pip install funboost,python全功能分布式函数调度框架,funboost的功能是全面性重量级,用户能想得到的功能99%全都有;funboost的使用方式是轻量级,只有@boost一行代码需要写。支持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=5I7ODkGKWrMzwwybl4YqebOj3ERs5lcIeqMTSaoCSaM,3956
|
|
2
2
|
funboost/__init__old.py,sha256=9Kv3cPLnPkbzMRnuJFVkPsuDdx1CdcSIuITkpdncZSc,20382
|
|
3
3
|
funboost/__main__.py,sha256=-6Nogi666Y0LN8fVm3JmHGTOk8xEGWvotW_GDbSaZME,1065
|
|
4
4
|
funboost/constant.py,sha256=STzRDZbuCC5FFV-uD_0r2beGsD1Zni4kregzR11z3Ok,8148
|
|
@@ -91,8 +91,8 @@ funboost/core/current_task.py,sha256=Oils18_vAqGvV4pqM6yYwnhMaFn3nrpzo1PO48HHidQ
|
|
|
91
91
|
funboost/core/exceptions.py,sha256=pLF7BkRJAfDiWp2_xGZqencmwdPiSQI1NENbImExknY,1311
|
|
92
92
|
funboost/core/fabric_deploy_helper.py,sha256=foieeqlNySuU9axJzNF6TavPjIUSYBx9UO3syVKUiyY,9999
|
|
93
93
|
funboost/core/funboost_config_getter.py,sha256=b5nAdAmUxahskY-ohB7ptf2gKywFlDA0Fq1cWroxxbs,384
|
|
94
|
-
funboost/core/funboost_time.py,sha256=
|
|
95
|
-
funboost/core/func_params_model.py,sha256=
|
|
94
|
+
funboost/core/funboost_time.py,sha256=a0MacbUBfYk8mf7D3UUyCxH5QJsu8YiGVXwJqPnSQH0,1779
|
|
95
|
+
funboost/core/func_params_model.py,sha256=eci_aHxXwUxtk3hS4YCUcZZSE5kKgSghuXpSLL87008,22225
|
|
96
96
|
funboost/core/function_result_status_config.py,sha256=PyjqAQOiwsLt28sRtH-eYRjiI3edPFO4Nde0ILFRReE,1764
|
|
97
97
|
funboost/core/function_result_status_saver.py,sha256=yHKZF9MjmhI-Q4Mkrka7DdweJ0wpgfLmgfAlsfkCeCk,9274
|
|
98
98
|
funboost/core/helper_funs.py,sha256=SsMa7A3iJyLek6v1qRK02kINebDp6kuAmlYkrYLXwQ0,2369
|
|
@@ -129,7 +129,7 @@ funboost/function_result_web/static/js/jquery-1.11.0.min.js,sha256=ryQZ3RXgnqkTz
|
|
|
129
129
|
funboost/function_result_web/templates/index.html,sha256=YM0582Q4t2da-xBf3Ga0McIfcsT9H98rjZck-irMkGo,20387
|
|
130
130
|
funboost/function_result_web/templates/login.html,sha256=q37dj7O0LeyiV38Zd5P1Qn_qmhjdFomuYTRY1Yk48Bo,2007
|
|
131
131
|
funboost/publishers/__init__.py,sha256=xqBHlvsJQVPfbdvP84G0LHmVB7-pFBS7vDnX1Uo9pVY,131
|
|
132
|
-
funboost/publishers/base_publisher.py,sha256=
|
|
132
|
+
funboost/publishers/base_publisher.py,sha256=WNKWxB8Cxp7sq06xlKIuYPhPQGf5de7KPG-GaxiOGZ0,17963
|
|
133
133
|
funboost/publishers/celery_publisher.py,sha256=uc9N1uLW74skUCw8dsnvxORM2O3cy4SiI7tUZRmvkHA,2336
|
|
134
134
|
funboost/publishers/celery_publisher000.py,sha256=2XLOyU2__vlIUTi5L15uf0BJqAIjxbc3kCLIRDSOY9w,3966
|
|
135
135
|
funboost/publishers/confluent_kafka_publisher.py,sha256=B4rF6gljixOMyN6L2eL1gzqTv97uoy7TTzgKUhHljEQ,4749
|
|
@@ -277,9 +277,9 @@ funboost/utils/pysnooper_ydf/utils.py,sha256=evSmGi_Oul7vSP47AJ0DLjFwoCYCfunJZ1m
|
|
|
277
277
|
funboost/utils/pysnooper_ydf/variables.py,sha256=QejRDESBA06KG9OH4sBT4J1M55eaU29EIHg8K_igaXo,3693
|
|
278
278
|
funboost/utils/times/__init__.py,sha256=Y4bQD3SIA_E7W2YvHq2Qdi0dGM4H2DxyFNdDOuFOq1w,2417
|
|
279
279
|
funboost/utils/times/version.py,sha256=11XfnZVVzOgIhXXdeN_mYfdXThfrsbQHpA0wCjz-hpg,17
|
|
280
|
-
funboost-
|
|
281
|
-
funboost-
|
|
282
|
-
funboost-
|
|
283
|
-
funboost-
|
|
284
|
-
funboost-
|
|
285
|
-
funboost-
|
|
280
|
+
funboost-47.0.dist-info/LICENSE,sha256=9EPP2ktG_lAPB8PjmWV-c9BiaJHc_FP6pPLcUrUwx0E,11562
|
|
281
|
+
funboost-47.0.dist-info/METADATA,sha256=u-iuOl9OJfo9tWgzCnEBo-iztqFCGA4qxa9j3ZmdjZY,32849
|
|
282
|
+
funboost-47.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
283
|
+
funboost-47.0.dist-info/entry_points.txt,sha256=BQMqRALuw-QT9x2d7puWaUHriXfy3wIzvfzF61AnSSI,97
|
|
284
|
+
funboost-47.0.dist-info/top_level.txt,sha256=K8WuKnS6MRcEWxP1NvbmCeujJq6TEfbsB150YROlRw0,9
|
|
285
|
+
funboost-47.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|