funboost 46.8__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/concurrent_pool/custom_threadpool_executor.py +5 -0
- funboost/consumers/base_consumer.py +11 -8
- funboost/core/funboost_time.py +1 -0
- funboost/core/func_params_model.py +16 -5
- funboost/publishers/base_publisher.py +8 -9
- funboost/timing_job/__init__.py +12 -15
- funboost/utils/time_util.py +17 -16
- {funboost-46.8.dist-info → funboost-47.0.dist-info}/METADATA +3 -3
- {funboost-46.8.dist-info → funboost-47.0.dist-info}/RECORD +14 -14
- {funboost-46.8.dist-info → funboost-47.0.dist-info}/LICENSE +0 -0
- {funboost-46.8.dist-info → funboost-47.0.dist-info}/WHEEL +0 -0
- {funboost-46.8.dist-info → funboost-47.0.dist-info}/entry_points.txt +0 -0
- {funboost-46.8.dist-info → funboost-47.0.dist-info}/top_level.txt +0 -0
funboost/__init__.py
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
可以在各种地方加入 time.sleep 来验证 第1条和第2条的自动智能缩放功能。
|
|
21
21
|
"""
|
|
22
|
+
import logging
|
|
23
|
+
|
|
22
24
|
import os
|
|
23
25
|
import atexit
|
|
24
26
|
import queue
|
|
@@ -175,6 +177,9 @@ class _CustomThread(threading.Thread, FunboostFileLoggerMixin, LoggerLevelSetter
|
|
|
175
177
|
# noinspection PyProtectedMember
|
|
176
178
|
def run(self):
|
|
177
179
|
# noinspection PyUnresolvedReferences
|
|
180
|
+
# print(logging.getLogger(None).level,logging.getLogger(None).handlers)
|
|
181
|
+
# print(self.logger.level)
|
|
182
|
+
# print(self.logger.handlers)
|
|
178
183
|
self.logger.debug(f'新启动线程 {self._ident} ')
|
|
179
184
|
self._executorx._change_threads_free_count(1)
|
|
180
185
|
while True:
|
|
@@ -13,6 +13,7 @@ import typing
|
|
|
13
13
|
import abc
|
|
14
14
|
import copy
|
|
15
15
|
from apscheduler.jobstores.memory import MemoryJobStore
|
|
16
|
+
from funboost.core.funboost_time import FunboostTime
|
|
16
17
|
from pathlib import Path
|
|
17
18
|
# from multiprocessing import Process
|
|
18
19
|
import datetime
|
|
@@ -401,11 +402,12 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
401
402
|
logger_apscheduler = get_logger('push_for_apscheduler_use_database_store', log_filename='push_for_apscheduler_use_database_store.log')
|
|
402
403
|
|
|
403
404
|
@classmethod
|
|
404
|
-
def
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
405
|
+
def _push_apscheduler_task_to_broker(cls, queue_name, msg, runonce_uuid):
|
|
406
|
+
funboost_lazy_impoter.BoostersManager.get_or_create_booster_by_queue_name(queue_name).publish(msg)
|
|
407
|
+
# key = 'apscheduler.redisjobstore_runonce'
|
|
408
|
+
# if RedisMixin().redis_db_frame.sadd(key, runonce_uuid): # 这样可以阻止多次启动同队列名消费者 redis jobstore多次运行函数.
|
|
409
|
+
# cls.logger_apscheduler.debug(f'延时任务用普通消息重新发布到普通队列 {msg}')
|
|
410
|
+
# funboost_lazy_impoter.BoostersManager.get_or_create_booster_by_queue_name(queue_name).publish(msg)
|
|
409
411
|
|
|
410
412
|
@abc.abstractmethod
|
|
411
413
|
def _shedual_task(self):
|
|
@@ -486,9 +488,10 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
486
488
|
run_date = None
|
|
487
489
|
# print(kw)
|
|
488
490
|
if msg_countdown:
|
|
489
|
-
run_date =
|
|
491
|
+
run_date = FunboostTime(kw['body']['extra']['publish_time']).datetime_obj + datetime.timedelta(seconds=msg_countdown)
|
|
490
492
|
if msg_eta:
|
|
491
|
-
|
|
493
|
+
|
|
494
|
+
run_date = FunboostTime(msg_eta).datetime_obj
|
|
492
495
|
# print(run_date,time_util.DatetimeConverter().datetime_obj)
|
|
493
496
|
# print(run_date.timestamp(),time_util.DatetimeConverter().datetime_obj.timestamp())
|
|
494
497
|
# print(self.concurrent_pool)
|
|
@@ -507,7 +510,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
507
510
|
self.__delete_eta_countdown(msg_no_delay)
|
|
508
511
|
# print(msg_no_delay)
|
|
509
512
|
# 数据库作为apscheduler的jobstores时候, 不能用 self.pbulisher_of_same_queue.publish,self不能序列化
|
|
510
|
-
self._delay_task_scheduler.add_job(self.
|
|
513
|
+
self._delay_task_scheduler.add_job(self._push_apscheduler_task_to_broker, 'date', run_date=run_date,
|
|
511
514
|
kwargs={'queue_name': self.queue_name, 'msg': msg_no_delay, 'runonce_uuid': str(uuid.uuid4())},
|
|
512
515
|
misfire_grace_time=misfire_grace_time,
|
|
513
516
|
)
|
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 = '' # 日志名字前缀,可以设置前缀
|
|
@@ -194,7 +197,8 @@ class BoosterParams(BaseJsonAbleModel):
|
|
|
194
197
|
broker_exclusive_config: dict = {} # 加上一个不同种类中间件非通用的配置,不同中间件自身独有的配置,不是所有中间件都兼容的配置,因为框架支持30种消息队列,消息队列不仅仅是一般的先进先出queue这么简单的概念,
|
|
195
198
|
# 例如kafka支持消费者组,rabbitmq也支持各种独特概念例如各种ack机制 复杂路由机制,有的中间件原生能支持消息优先级有的中间件不支持,每一种消息队列都有独特的配置参数意义,可以通过这里传递。每种中间件能传递的键值对可以看consumer类的 BROKER_EXCLUSIVE_CONFIG_DEFAULT
|
|
196
199
|
|
|
197
|
-
should_check_publish_func_params: bool = True # 消息发布时候是否校验消息发布内容,比如有的人发布消息,函数只接受a,b两个入参,他去传2
|
|
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
|
|
|
@@ -283,7 +292,7 @@ class PriorityConsumingControlConfig(BaseJsonAbleModel):
|
|
|
283
292
|
is_using_rpc_mode: bool = None
|
|
284
293
|
|
|
285
294
|
countdown: typing.Union[float, int] = None
|
|
286
|
-
eta: datetime.datetime = None
|
|
295
|
+
eta: typing.Union[datetime.datetime, str] = None # 时间对象, 或 %Y-%m-%d %H:%M:%S 字符串。
|
|
287
296
|
misfire_grace_time: typing.Union[int, None] = None
|
|
288
297
|
|
|
289
298
|
other_extra_params: dict = None # 其他参数, 例如消息优先级 , priority_control_config=PriorityConsumingControlConfig(other_extra_params={'priroty': priorityxx}),
|
|
@@ -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)
|
funboost/timing_job/__init__.py
CHANGED
|
@@ -2,35 +2,29 @@
|
|
|
2
2
|
集成定时任务。
|
|
3
3
|
"""
|
|
4
4
|
import atexit
|
|
5
|
-
import copy
|
|
6
|
-
import importlib
|
|
7
|
-
|
|
8
|
-
import pickle
|
|
9
5
|
|
|
10
6
|
import time
|
|
11
7
|
from apscheduler.executors.pool import BasePoolExecutor
|
|
12
8
|
|
|
13
|
-
from funboost.utils.decorators import RedisDistributedLockContextManager,RedisDistributedBlockLockContextManager
|
|
14
9
|
from typing import Union
|
|
15
10
|
import threading
|
|
16
11
|
|
|
17
12
|
from apscheduler.schedulers.background import BackgroundScheduler
|
|
18
|
-
from apscheduler.jobstores.redis import RedisJobStore
|
|
19
13
|
# noinspection PyProtectedMember
|
|
20
14
|
from apscheduler.schedulers.base import STATE_STOPPED, STATE_RUNNING
|
|
21
|
-
from apscheduler.util import undefined,TIMEOUT_MAX
|
|
15
|
+
from apscheduler.util import undefined, TIMEOUT_MAX
|
|
22
16
|
import deprecated
|
|
23
17
|
from funboost.utils.redis_manager import RedisMixin
|
|
24
18
|
|
|
25
|
-
from funboost.funboost_config_deafult import
|
|
19
|
+
from funboost.funboost_config_deafult import FunboostCommonConfig
|
|
26
20
|
|
|
27
21
|
from funboost.consumers.base_consumer import AbstractConsumer
|
|
28
22
|
from funboost.core.booster import BoostersManager, Booster
|
|
29
|
-
|
|
23
|
+
|
|
30
24
|
from funboost import BoosterParams
|
|
31
|
-
from funboost.concurrent_pool.flexible_thread_pool import FlexibleThreadPool
|
|
32
25
|
from funboost.concurrent_pool.custom_threadpool_executor import ThreadPoolExecutorShrinkAble
|
|
33
26
|
|
|
27
|
+
|
|
34
28
|
@deprecated.deprecated(reason='以后不要再使用这种方式,对于job_store为数据库时候需要序列化不好。使用内存和数据库都兼容的添加任务方式: add_push_job')
|
|
35
29
|
def timing_publish_deco(consuming_func_decorated_or_consumer: Union[callable, AbstractConsumer]):
|
|
36
30
|
def _deco(*args, **kwargs):
|
|
@@ -49,14 +43,16 @@ def push_fun_params_to_broker(queue_name: str, *args, runonce_uuid=None, **kwarg
|
|
|
49
43
|
queue_name 队列名字
|
|
50
44
|
*args **kwargs 是消费函数的入参
|
|
51
45
|
发布消息中可以包括,runonce_uuid这个入参,确保分布式多个脚本都启动了定时器,导致每个定时器重复发布到消息队列,值你自己写 str(uuid.uuid4())
|
|
46
|
+
# 不需要传递 runonce_uuid 了,已经用专门的 FunboostBackgroundSchedulerProcessJobsWithinRedisLock 解决了。
|
|
52
47
|
"""
|
|
53
|
-
if runonce_uuid:
|
|
48
|
+
if runonce_uuid: # 不需要传递 runonce_uuid 了,已经用专门的 FunboostBackgroundSchedulerProcessJobsWithinRedisLock 解决了 process_jobs的问题。
|
|
54
49
|
key = 'apscheduler.redisjobstore_runonce2'
|
|
55
50
|
if RedisMixin().redis_db_frame.sadd(key, runonce_uuid):
|
|
56
51
|
BoostersManager.get_or_create_booster_by_queue_name(queue_name).push(*args, **kwargs)
|
|
57
52
|
else:
|
|
58
53
|
BoostersManager.get_or_create_booster_by_queue_name(queue_name).push(*args, **kwargs)
|
|
59
54
|
|
|
55
|
+
|
|
60
56
|
class ThreadPoolExecutorForAps(BasePoolExecutor):
|
|
61
57
|
"""
|
|
62
58
|
An executor that runs jobs in a concurrent.futures thread pool.
|
|
@@ -68,10 +64,11 @@ class ThreadPoolExecutorForAps(BasePoolExecutor):
|
|
|
68
64
|
ThreadPoolExecutor constructor
|
|
69
65
|
"""
|
|
70
66
|
|
|
71
|
-
def __init__(self, max_workers=10, ):
|
|
72
|
-
pool = ThreadPoolExecutorShrinkAble(int(max_workers),)
|
|
67
|
+
def __init__(self, max_workers=10, pool_kwargs=None):
|
|
68
|
+
pool = ThreadPoolExecutorShrinkAble(int(max_workers), )
|
|
73
69
|
super().__init__(pool)
|
|
74
70
|
|
|
71
|
+
|
|
75
72
|
class FunboostBackgroundScheduler(BackgroundScheduler):
|
|
76
73
|
"""
|
|
77
74
|
自定义的, 继承了官方BackgroundScheduler,
|
|
@@ -126,7 +123,7 @@ class FunboostBackgroundScheduler(BackgroundScheduler):
|
|
|
126
123
|
args_list.insert(0, func.queue_name)
|
|
127
124
|
args = tuple(args_list)
|
|
128
125
|
kwargs = kwargs or {}
|
|
129
|
-
kwargs['runonce_uuid'] = runonce_uuid
|
|
126
|
+
kwargs['runonce_uuid'] = runonce_uuid # 忽略,用户不需要传递runonce_uuid入参。
|
|
130
127
|
return self.add_job(push_fun_params_to_broker, trigger, args, kwargs, id, name,
|
|
131
128
|
misfire_grace_time, coalesce, max_instances,
|
|
132
129
|
next_run_time, jobstore, executor,
|
|
@@ -173,7 +170,7 @@ class FunboostBackgroundScheduler(BackgroundScheduler):
|
|
|
173
170
|
if wait_seconds is None:
|
|
174
171
|
wait_seconds = MAX_WAIT_SECONDS_FOR_NEX_PROCESS_JOBS
|
|
175
172
|
self._last_wait_seconds = min(wait_seconds, MAX_WAIT_SECONDS_FOR_NEX_PROCESS_JOBS)
|
|
176
|
-
if wait_seconds in (None,TIMEOUT_MAX):
|
|
173
|
+
if wait_seconds in (None, TIMEOUT_MAX):
|
|
177
174
|
self._last_has_task = False
|
|
178
175
|
else:
|
|
179
176
|
self._last_has_task = True
|
funboost/utils/time_util.py
CHANGED
|
@@ -5,7 +5,7 @@ import datetime
|
|
|
5
5
|
import time
|
|
6
6
|
import re
|
|
7
7
|
import pytz
|
|
8
|
-
|
|
8
|
+
from funboost.core.funboost_time import FunboostTime
|
|
9
9
|
|
|
10
10
|
from funboost.utils import nb_print
|
|
11
11
|
|
|
@@ -75,21 +75,22 @@ class DatetimeConverter:
|
|
|
75
75
|
"""
|
|
76
76
|
:param datetimex: 接受时间戳 datatime类型 和 时间字符串三种类型
|
|
77
77
|
"""
|
|
78
|
-
if isinstance(datetimex, str):
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
elif isinstance(datetimex, (int, float)):
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
elif isinstance(datetimex, datetime.datetime):
|
|
88
|
-
|
|
89
|
-
elif datetimex is None:
|
|
90
|
-
|
|
91
|
-
else:
|
|
92
|
-
|
|
78
|
+
# if isinstance(datetimex, str):
|
|
79
|
+
# if not re.match(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}', datetimex):
|
|
80
|
+
# raise ValueError('时间字符串的格式不符合此传参的规定')
|
|
81
|
+
# else:
|
|
82
|
+
# self.datetime_obj = datetime.datetime.strptime(datetimex, self.DATETIME_FORMATTER)
|
|
83
|
+
# elif isinstance(datetimex, (int, float)):
|
|
84
|
+
# if datetimex < 1:
|
|
85
|
+
# datetimex += 86400
|
|
86
|
+
# self.datetime_obj = datetime.datetime.fromtimestamp(datetimex, tz=pytz.timezone(_get_funboost_timezone())) # 时间戳0在windows会出错。
|
|
87
|
+
# elif isinstance(datetimex, datetime.datetime):
|
|
88
|
+
# self.datetime_obj = datetimex
|
|
89
|
+
# elif datetimex is None:
|
|
90
|
+
# self.datetime_obj = datetime.datetime.now(tz=pytz.timezone(_get_funboost_timezone()))
|
|
91
|
+
# else:
|
|
92
|
+
# raise ValueError('实例化时候的传参不符合规定')
|
|
93
|
+
self.datetime_obj = FunboostTime(datetimex).datetime_obj
|
|
93
94
|
|
|
94
95
|
@property
|
|
95
96
|
def datetime_str(self):
|
|
@@ -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
|
|
@@ -26,9 +26,9 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
26
26
|
Classifier: Topic :: Software Development :: Libraries
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
License-File: LICENSE
|
|
29
|
-
Requires-Dist: nb-log (>=
|
|
29
|
+
Requires-Dist: nb-log (>=13.2)
|
|
30
30
|
Requires-Dist: nb-libs (>=1.8)
|
|
31
|
-
Requires-Dist: nb-time (>=
|
|
31
|
+
Requires-Dist: nb-time (>=2.0)
|
|
32
32
|
Requires-Dist: pymongo (==4.3.3)
|
|
33
33
|
Requires-Dist: AMQPStorm (==2.10.6)
|
|
34
34
|
Requires-Dist: rabbitpy (==2.0.1)
|
|
@@ -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
|
|
@@ -24,7 +24,7 @@ funboost/concurrent_pool/bounded_threadpoolexcutor.py,sha256=AWFsTwK7hIiln0XVaiY
|
|
|
24
24
|
funboost/concurrent_pool/concurrent_pool_with_multi_process.py,sha256=qChdRh11Epk7-kmLEdoB1TtM2plx_FZ1u_-g0KNc-MU,1744
|
|
25
25
|
funboost/concurrent_pool/custom_evenlet_pool_executor.py,sha256=tu8Og-uIt5VWqGERnIihBaF7ZFw5D0xww1_ur39OZXY,3252
|
|
26
26
|
funboost/concurrent_pool/custom_gevent_pool_executor.py,sha256=FLcEwEJgFtaEPzH-WCFHtCdEUOTeK0dLSL_oNBcXQW8,5429
|
|
27
|
-
funboost/concurrent_pool/custom_threadpool_executor.py,sha256=
|
|
27
|
+
funboost/concurrent_pool/custom_threadpool_executor.py,sha256=hYgRYqFoCvplyQFTzw57P-oRcmO6ZuxW5qB3U1SPZks,12084
|
|
28
28
|
funboost/concurrent_pool/custom_threadpool_executor000.py,sha256=jJLXy3h-bELap6nZA6yLtdozzTWcvCtZ7IY6MTqLEAM,9317
|
|
29
29
|
funboost/concurrent_pool/fixed_thread_pool.py,sha256=JzaqjuHn6ffo1gZRVJEy5Te5NdCJt7heTmsVZT_AiBg,1609
|
|
30
30
|
funboost/concurrent_pool/flexible_thread_pool.py,sha256=-xvRYcSzh-oNVtDkEsMreRPW6sadQ6PFsN35XzLOdAU,6040
|
|
@@ -35,7 +35,7 @@ funboost/concurrent_pool/backup/async_pool_executor0223.py,sha256=RVUZiylUvpTm6U
|
|
|
35
35
|
funboost/concurrent_pool/backup/async_pool_executor_back.py,sha256=KL6zEQaa1KkZOlAO85mCC1gwLm-YC5Ghn21IUom0UKM,9598
|
|
36
36
|
funboost/concurrent_pool/backup/async_pool_executor_janus.py,sha256=OHMWJ9l3EYTpPpcrPrGGKd4K0tmQ2PN8HiX0Dta0EOo,5728
|
|
37
37
|
funboost/consumers/__init__.py,sha256=ZXY_6Kut1VYNQiF5aWEgIWobsW1ht9YUP0TdRZRWFqI,126
|
|
38
|
-
funboost/consumers/base_consumer.py,sha256=
|
|
38
|
+
funboost/consumers/base_consumer.py,sha256=QznnVHhGFf_4tQFk0hXes0mo4oeIeKp-EjPiuryurYo,82376
|
|
39
39
|
funboost/consumers/celery_consumer.py,sha256=nQpSkzPBJ4bRpxn4i9ms0axrJiq9RWhb4lG2nAdCIig,9254
|
|
40
40
|
funboost/consumers/confirm_mixin.py,sha256=5xC9AAQr_MY4tbSed8U-M6tOVmh69Qv9X0ld0JLT9Tk,6185
|
|
41
41
|
funboost/consumers/dramatiq_consumer.py,sha256=ozmeAfeF0U-YNYHK4suQB0N264h5AZdfMH0O45Mh-8A,2229
|
|
@@ -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
|
|
@@ -172,7 +172,7 @@ funboost/queues/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
172
172
|
funboost/queues/memory_queues_map.py,sha256=e1S_cnjnCVI4DBsA_iupF51S_eX4OvCtlefQCqS1TYA,424
|
|
173
173
|
funboost/queues/peewee_queue.py,sha256=FrwegrilkHZG6Y1cGdl5Bt_UtA25f7m5TJQJMZ9YnJI,5280
|
|
174
174
|
funboost/queues/sqla_queue.py,sha256=b-2QPvvuMxklm41ibZhGKehaAV9trXBQFCOHzgThx_s,11080
|
|
175
|
-
funboost/timing_job/__init__.py,sha256=
|
|
175
|
+
funboost/timing_job/__init__.py,sha256=jaXuyA1O5JnpIJfxzQijOPHP9sI92n8TSVZEr8iBTFM,10340
|
|
176
176
|
funboost/timing_job/apscheduler_use_mysql_store.py,sha256=ss92DiSLzbWuVIo19sTLgC99GessltWLOlqqOd4AIL4,471
|
|
177
177
|
funboost/timing_job/apscheduler_use_redis_store.py,sha256=RNZVerUTTzpSFMFEHWkDrUOSz71B4Ml_hlcavkL1tAA,2933
|
|
178
178
|
funboost/utils/__init__.py,sha256=rAyXE7lgCo_3VdMvGrIJiqsTHv2nZPTJDTj1f6s_KgE,586
|
|
@@ -198,7 +198,7 @@ funboost/utils/resource_monitoring.py,sha256=EWq7hqQLM2hYpbkv4sVw9YcpHLxfg8arcGz
|
|
|
198
198
|
funboost/utils/restart_python.py,sha256=bFbV0_24ajL8hBwVRLxWe9v9kTwiX1fGLhXRroNnmgQ,1418
|
|
199
199
|
funboost/utils/simple_data_class.py,sha256=AVaMOyM2o7fszFoG6U8qGly7fIUZt10o5x5mIFYzI9k,2277
|
|
200
200
|
funboost/utils/str_utils.py,sha256=Mxi8BW3-QTBozxioTKpmEh00hOibT-_5dctMjz4miUs,1608
|
|
201
|
-
funboost/utils/time_util.py,sha256=
|
|
201
|
+
funboost/utils/time_util.py,sha256=5Aw0mLTjXfWFmijCcS8XbBEDjzpLaMcl2UBqMS9LJIw,5681
|
|
202
202
|
funboost/utils/un_strict_json_dumps.py,sha256=uh2mXNRCq5dJcqMhb9CkfvehfEGYZAgI6RY1oLcYX_M,408
|
|
203
203
|
funboost/utils/dependency_packages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
204
204
|
funboost/utils/dependency_packages/mongomq/__init__.py,sha256=yP7LHPsZ5ResiexksmtyJc9HGbMJWwZ0gOvHk2vNcz0,131
|
|
@@ -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
|