funboost 44.2__py3-none-any.whl → 44.3__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 +17 -10
- funboost/consumers/http_consumer.py +1 -1
- funboost/consumers/http_consumer000.py +1 -2
- funboost/consumers/httpsqs_consumer.py +1 -1
- funboost/consumers/kafka_consumer.py +1 -1
- funboost/consumers/kafka_consumer_manually_commit.py +2 -2
- funboost/consumers/kombu_consumer.py +0 -1
- funboost/consumers/local_python_queue_consumer.py +2 -3
- funboost/consumers/memory_deque_consumer.py +0 -3
- funboost/consumers/mongomq_consumer.py +0 -1
- funboost/consumers/mqtt_consumer.py +1 -1
- funboost/consumers/nats_consumer.py +1 -1
- funboost/consumers/nsq_consumer.py +1 -2
- funboost/consumers/peewee_conusmer.py +1 -2
- funboost/consumers/persist_queue_consumer.py +1 -2
- funboost/consumers/pulsar_consumer.py +1 -2
- funboost/consumers/rabbitmq_amqpstorm_consumer.py +0 -2
- funboost/consumers/rabbitmq_pika_consumer.py +0 -2
- funboost/consumers/rabbitmq_pika_consumerv0.py +0 -1
- funboost/consumers/rabbitmq_rabbitpy_consumer.py +1 -2
- funboost/consumers/redis_brpoplpush_consumer.py +1 -3
- funboost/consumers/redis_consumer.py +4 -8
- funboost/consumers/redis_consumer_ack_able.py +5 -10
- funboost/consumers/redis_consumer_priority.py +3 -7
- funboost/consumers/redis_consumer_simple.py +2 -3
- funboost/consumers/redis_pubsub_consumer.py +3 -3
- funboost/consumers/redis_stream_consumer.py +3 -3
- funboost/consumers/rocketmq_consumer.py +2 -2
- funboost/consumers/sqlachemy_consumer.py +1 -1
- funboost/consumers/tcp_consumer.py +2 -2
- funboost/consumers/txt_file_consumer.py +2 -2
- funboost/consumers/udp_consumer.py +2 -2
- funboost/consumers/zeromq_consumer.py +1 -2
- funboost/core/cli/discovery_boosters.py +2 -2
- funboost/core/lazy_impoter.py +30 -37
- funboost/core/muliti_process_enhance.py +3 -3
- funboost/utils/decorators.py +14 -0
- funboost/utils/paramiko_util.py +1 -1
- {funboost-44.2.dist-info → funboost-44.3.dist-info}/METADATA +1 -1
- {funboost-44.2.dist-info → funboost-44.3.dist-info}/RECORD +45 -45
- {funboost-44.2.dist-info → funboost-44.3.dist-info}/LICENSE +0 -0
- {funboost-44.2.dist-info → funboost-44.3.dist-info}/WHEEL +0 -0
- {funboost-44.2.dist-info → funboost-44.3.dist-info}/entry_points.txt +0 -0
- {funboost-44.2.dist-info → funboost-44.3.dist-info}/top_level.txt +0 -0
funboost/__init__.py
CHANGED
|
@@ -71,7 +71,7 @@ from funboost.core import kill_remote_task
|
|
|
71
71
|
from funboost.core.exceptions import ExceptionForRequeue, ExceptionForPushToDlxqueue
|
|
72
72
|
|
|
73
73
|
# from funboost.core.booster import BoostersManager 互相导入
|
|
74
|
-
from funboost.core.lazy_impoter import
|
|
74
|
+
from funboost.core.lazy_impoter import funboost_lazy_impoter
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
# patch_apscheduler_run_job()
|
|
@@ -174,6 +174,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
174
174
|
broker_exclusive_config_merge = dict()
|
|
175
175
|
broker_exclusive_config_merge.update(self.BROKER_EXCLUSIVE_CONFIG_DEFAULT)
|
|
176
176
|
broker_exclusive_config_merge.update(self.consumer_params.broker_exclusive_config)
|
|
177
|
+
# print(broker_exclusive_config_merge)
|
|
177
178
|
self.consumer_params.broker_exclusive_config = broker_exclusive_config_merge
|
|
178
179
|
|
|
179
180
|
self._stop_flag = None
|
|
@@ -222,7 +223,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
222
223
|
# log_filename=consumer_params.log_filename,
|
|
223
224
|
# logger_name=consumer_params.logger_name,
|
|
224
225
|
# broker_exclusive_config=self.consumer_params.broker_exclusive_config)
|
|
225
|
-
self.publisher_params = BaseJsonAbleModel.init_by_another_model(PublisherParams, consumer_params)
|
|
226
|
+
self.publisher_params = BaseJsonAbleModel.init_by_another_model(PublisherParams, self.consumer_params)
|
|
226
227
|
# print(self.publisher_params)
|
|
227
228
|
if is_main_process:
|
|
228
229
|
self.logger.info(f'{self.queue_name} consumer 的消费者配置:\n {self.consumer_params.json_str_value()}')
|
|
@@ -322,11 +323,11 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
322
323
|
# ConsumersManager.show_all_consumer_info()
|
|
323
324
|
# noinspection PyBroadException
|
|
324
325
|
pid_queue_name_tuple = (os.getpid(), self.queue_name)
|
|
325
|
-
if pid_queue_name_tuple in
|
|
326
|
+
if pid_queue_name_tuple in funboost_lazy_impoter.BoostersManager.pid_queue_name__has_start_consume_set:
|
|
326
327
|
self.logger.warning(f'{pid_queue_name_tuple} 已启动消费,不要一直去启动消费,funboost框架自动阻止.') # 有的人乱写代码,无数次在函数内部或for循环里面执行 f.consume(),一个队列只需要启动一次消费,不然每启动一次性能消耗很大,直到程序崩溃
|
|
327
328
|
return
|
|
328
329
|
else:
|
|
329
|
-
|
|
330
|
+
funboost_lazy_impoter.BoostersManager.pid_queue_name__has_start_consume_set.add(pid_queue_name_tuple)
|
|
330
331
|
GlobalVars.has_start_a_consumer_flag = True
|
|
331
332
|
try:
|
|
332
333
|
self._concurrent_mode_dispatcher.check_all_concurrent_mode()
|
|
@@ -373,7 +374,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
373
374
|
key = 'apscheduler.redisjobstore_runonce'
|
|
374
375
|
if RedisMixin().redis_db_frame.sadd(key, runonce_uuid): # 这样可以阻止多次启动同队列名消费者 redis jobstore多次运行函数.
|
|
375
376
|
cls.logger_apscheduler.debug(f'延时任务用普通消息重新发布到普通队列 {msg}')
|
|
376
|
-
|
|
377
|
+
funboost_lazy_impoter.BoostersManager.get_or_create_booster_by_queue_name(queue_name).publish(msg)
|
|
377
378
|
|
|
378
379
|
@abc.abstractmethod
|
|
379
380
|
def _shedual_task(self):
|
|
@@ -383,7 +384,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
383
384
|
"""
|
|
384
385
|
raise NotImplementedError
|
|
385
386
|
|
|
386
|
-
def convert_msg_before_run(self, msg: dict):
|
|
387
|
+
def convert_msg_before_run(self, msg: typing.Union[str,dict]):
|
|
387
388
|
"""
|
|
388
389
|
转换消息,消息没有使用funboost来发送,并且没有extra相关字段时候
|
|
389
390
|
用户也可以按照4.21文档,继承任意Consumer类,并实现这个方法 convert_msg_before_run,先转换消息.
|
|
@@ -404,6 +405,9 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
404
405
|
extra_params = {'task_id': task_id, 'publish_time': round(time.time(), 4),
|
|
405
406
|
'publish_time_format': time.strftime('%Y-%m-%d %H:%M:%S')}
|
|
406
407
|
"""
|
|
408
|
+
if isinstance(msg,str):
|
|
409
|
+
msg = json.loads(msg)
|
|
410
|
+
# 以下是清洗补全字段.
|
|
407
411
|
if 'extra' not in msg:
|
|
408
412
|
msg['extra'] = {'is_auto_fill_extra': True}
|
|
409
413
|
extra = msg['extra']
|
|
@@ -413,6 +417,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
413
417
|
extra['publish_time'] = MsgGenerater.generate_publish_time()
|
|
414
418
|
if 'publish_time_format':
|
|
415
419
|
extra['publish_time_format'] = MsgGenerater.generate_publish_time_format()
|
|
420
|
+
return msg
|
|
416
421
|
|
|
417
422
|
def _submit_task(self, kw):
|
|
418
423
|
while 1: # 这一块的代码为支持暂停消费。
|
|
@@ -424,12 +429,13 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
424
429
|
self._last_show_pause_log_time = time.time()
|
|
425
430
|
else:
|
|
426
431
|
break
|
|
427
|
-
|
|
432
|
+
msg = kw['body']
|
|
433
|
+
self._print_message_get_from_broker(msg)
|
|
434
|
+
kw['body'] = self.convert_msg_before_run(msg)
|
|
428
435
|
if self._judge_is_daylight():
|
|
429
436
|
self._requeue(kw)
|
|
430
437
|
time.sleep(self.time_interval_for_check_do_not_run_time)
|
|
431
438
|
return
|
|
432
|
-
self.convert_msg_before_run(kw['body'])
|
|
433
439
|
function_only_params = delete_keys_and_return_new_dict(kw['body'], )
|
|
434
440
|
if self._get_priority_conf(kw, 'do_task_filtering') and self._redis_filter.check_value_exists(
|
|
435
441
|
function_only_params): # 对函数的参数进行检查,过滤已经执行过并且成功的任务。
|
|
@@ -524,12 +530,13 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
524
530
|
if self._has_execute_times_in_recent_second >= qpsx:
|
|
525
531
|
time.sleep((1 - (time.time() - self._last_start_count_qps_timestamp)) * 1)
|
|
526
532
|
|
|
527
|
-
def _print_message_get_from_broker(self, broker_name
|
|
533
|
+
def _print_message_get_from_broker(self, msg,broker_name=None):
|
|
528
534
|
# print(999)
|
|
529
535
|
if self.consumer_params.is_show_message_get_from_broker:
|
|
530
536
|
if isinstance(msg, (dict, list)):
|
|
531
537
|
msg = json.dumps(msg, ensure_ascii=False)
|
|
532
|
-
self.logger.debug(f'从 {broker_name} 中间件 的 {self._queue_name} 中取出的消息是 {msg}')
|
|
538
|
+
# self.logger.debug(f'从 {broker_name} 中间件 的 {self._queue_name} 中取出的消息是 {msg}')
|
|
539
|
+
self.logger.debug(f'从 {broker_name or self.consumer_params.broker_kind} 中间件 的 {self._queue_name} 中取出的消息是 {msg}')
|
|
533
540
|
|
|
534
541
|
def _get_priority_conf(self, kw: dict, broker_task_config_key: str):
|
|
535
542
|
broker_task_config = kw['body'].get('extra', {}).get(broker_task_config_key, None)
|
|
@@ -49,7 +49,7 @@ class HTTPConsumer(AbstractConsumer, ):
|
|
|
49
49
|
async def recv_msg(request: AioHttpImporter().Request):
|
|
50
50
|
data = await request.post()
|
|
51
51
|
msg = data['msg']
|
|
52
|
-
kw = {'body':
|
|
52
|
+
kw = {'body': msg}
|
|
53
53
|
self._submit_task(kw)
|
|
54
54
|
return AioHttpImporter().web.Response(text="finish")
|
|
55
55
|
|
|
@@ -60,8 +60,7 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|
|
60
60
|
if self.path == '/queue':
|
|
61
61
|
msg = form['msg'].value
|
|
62
62
|
# print(msg)
|
|
63
|
-
|
|
64
|
-
kw = {'body': json.loads(msg)}
|
|
63
|
+
kw = {'body': msg}
|
|
65
64
|
self.consumer._submit_task(kw)
|
|
66
65
|
|
|
67
66
|
# 开始回复
|
|
@@ -61,7 +61,7 @@ class KafkaConsumer(AbstractConsumer):
|
|
|
61
61
|
if self.consumer_params.is_show_message_get_from_broker:
|
|
62
62
|
self.logger.debug(
|
|
63
63
|
f'从kafka的 [{message.topic}] 主题,分区 {message.partition} 中 取出的消息是: {message.value.decode()}')
|
|
64
|
-
kw = {'consumer': consumer, 'message': message, 'body':
|
|
64
|
+
kw = {'consumer': consumer, 'message': message, 'body': message.value}
|
|
65
65
|
self._submit_task(kw)
|
|
66
66
|
|
|
67
67
|
def _confirm_consume(self, kw):
|
|
@@ -66,7 +66,7 @@ class KafkaConsumerManuallyCommit(AbstractConsumer):
|
|
|
66
66
|
# value() offset() partition()
|
|
67
67
|
# print('Received message: {}'.format(msg.value().decode('utf-8'))) # noqa
|
|
68
68
|
self._partion__offset_consume_status_map[msg.partition()][msg.offset()] = 0
|
|
69
|
-
kw = {'partition': msg.partition(), 'offset': msg.offset(), 'body':
|
|
69
|
+
kw = {'partition': msg.partition(), 'offset': msg.offset(), 'body': msg.value()} # noqa
|
|
70
70
|
if self.consumer_params.is_show_message_get_from_broker:
|
|
71
71
|
self.logger.debug(
|
|
72
72
|
f'从kafka的 [{self._queue_name}] 主题,分区 {msg.partition()} 中 的 offset {msg.offset()} 取出的消息是: {msg.value()}') # noqa
|
|
@@ -165,7 +165,7 @@ class SaslPlainKafkaConsumer(KafkaConsumerManuallyCommit):
|
|
|
165
165
|
# print('Received message: {}'.format(msg.value().decode('utf-8'))) # noqa
|
|
166
166
|
self._partion__offset_consume_status_map[msg.partition(
|
|
167
167
|
)][msg.offset()] = 0
|
|
168
|
-
kw = {'partition': msg.partition(), 'offset': msg.offset(), 'body':
|
|
168
|
+
kw = {'partition': msg.partition(), 'offset': msg.offset(), 'body': msg.value()} # noqa
|
|
169
169
|
if self.consumer_params.is_show_message_get_from_broker:
|
|
170
170
|
self.logger.debug(
|
|
171
171
|
f'从kafka的 [{self._queue_name}] 主题,分区 {msg.partition()} 中 的 offset {msg.offset()} 取出的消息是: {msg.value()}') # noqa
|
|
@@ -194,7 +194,6 @@ Transport Options
|
|
|
194
194
|
|
|
195
195
|
def callback(body: dict, message: Message):
|
|
196
196
|
# print(type(body),body,type(message),message)
|
|
197
|
-
self._print_message_get_from_broker('kombu', body)
|
|
198
197
|
# self.logger.debug(f""" 从 kombu {self._middware_name} 中取出的消息是 {body}""")
|
|
199
198
|
kw = {'body': body, 'message': message, }
|
|
200
199
|
self._submit_task(kw)
|
|
@@ -20,9 +20,8 @@ class LocalPythonQueueConsumer(AbstractConsumer):
|
|
|
20
20
|
def _shedual_task(self):
|
|
21
21
|
while True:
|
|
22
22
|
task = self.local_python_queue.get()
|
|
23
|
-
if isinstance(task,
|
|
24
|
-
task = json.
|
|
25
|
-
self._print_message_get_from_broker('当前python解释器内部', task)
|
|
23
|
+
if isinstance(task, dict):
|
|
24
|
+
task = json.dumps(task)
|
|
26
25
|
# self.logger.debug(f'从当前python解释器内部的 [{self._queue_name}] 队列中 取出的消息是: {json.dumps(task)} ')
|
|
27
26
|
kw = {'body': task}
|
|
28
27
|
self._submit_task(kw)
|
|
@@ -21,9 +21,6 @@ class LocalPythonQueueConsumer(AbstractConsumer):
|
|
|
21
21
|
def _shedual_task(self):
|
|
22
22
|
while True:
|
|
23
23
|
task = self.local_python_queue.popleft()
|
|
24
|
-
if isinstance(task, str):
|
|
25
|
-
task = json.loads(task)
|
|
26
|
-
self._print_message_get_from_broker('当前python解释器内部', task)
|
|
27
24
|
# self.logger.debug(f'从当前python解释器内部的 [{self._queue_name}] 队列中 取出的消息是: {json.dumps(task)} ')
|
|
28
25
|
kw = {'body': task}
|
|
29
26
|
self._submit_task(kw)
|
|
@@ -19,7 +19,6 @@ class MongoMqConsumer(AbstractConsumer, MongoMixin):
|
|
|
19
19
|
job = mp.queue.next()
|
|
20
20
|
if job is not None:
|
|
21
21
|
# self.logger.debug(f'从mongo的 [{self._queue_name}] 队列中 取出的消息是: 消息是: {job.payload} ')
|
|
22
|
-
self._print_message_get_from_broker('mongo', job.payload)
|
|
23
22
|
kw = {'body': job.payload, 'job': job}
|
|
24
23
|
self._submit_task(kw)
|
|
25
24
|
else:
|
|
@@ -48,7 +48,7 @@ class MqttConsumer(AbstractConsumer):
|
|
|
48
48
|
# noinspection PyUnusedLocal
|
|
49
49
|
def _on_message(self, client, userdata, msg):
|
|
50
50
|
# print(msg.topic + " " + str(msg.payload))
|
|
51
|
-
kw = {'body':
|
|
51
|
+
kw = {'body': msg.payload}
|
|
52
52
|
self._submit_task(kw)
|
|
53
53
|
|
|
54
54
|
def _confirm_consume(self, kw):
|
|
@@ -21,7 +21,7 @@ class NatsConsumer(AbstractConsumer):
|
|
|
21
21
|
# print(type(msg))
|
|
22
22
|
# print(msg.reply)
|
|
23
23
|
# print(f"Received a message with subject {msg.subject}: {msg.payload}")
|
|
24
|
-
kw = {'body':
|
|
24
|
+
kw = {'body': msg.payload}
|
|
25
25
|
self._submit_task(kw)
|
|
26
26
|
|
|
27
27
|
nats_client.subscribe(subject=self.queue_name, callback=callback)
|
|
@@ -27,10 +27,9 @@ class NsqConsumer(AbstractConsumer):
|
|
|
27
27
|
@consumer.on_message.connect
|
|
28
28
|
def handler(consumerx: GnsqImporter().Consumer, message: GnsqImporter().Message):
|
|
29
29
|
# 第一条消息不能并发,第一条消息之后可以并发。
|
|
30
|
-
self._print_message_get_from_broker('nsq', message.body.decode())
|
|
31
30
|
# self.logger.debug(f'从nsq的 [{self._queue_name}] 主题中 取出的消息是: {message.body.decode()}')
|
|
32
31
|
message.enable_async()
|
|
33
|
-
kw = {'consumer': consumerx, 'message': message, 'body':
|
|
32
|
+
kw = {'consumer': consumerx, 'message': message, 'body': message.body}
|
|
34
33
|
self._submit_task(kw)
|
|
35
34
|
|
|
36
35
|
consumer.start()
|
|
@@ -20,8 +20,7 @@ class PeeweeConsumer(AbstractConsumer):
|
|
|
20
20
|
task_dict = self.queue.get()
|
|
21
21
|
# print(task_dict)
|
|
22
22
|
# self.logger.debug(f'从数据库 {frame_config.SQLACHEMY_ENGINE_URL[:25]}。。 的 [{self._queue_name}] 队列中 取出的消息是: 消息是: {sqla_task_dict}')
|
|
23
|
-
|
|
24
|
-
kw = {'body':json.loads(task_dict['body']), 'job_id': task_dict['job_id']}
|
|
23
|
+
kw = {'body':task_dict['body'], 'job_id': task_dict['job_id']}
|
|
25
24
|
self._submit_task(kw)
|
|
26
25
|
|
|
27
26
|
def _confirm_consume(self, kw):
|
|
@@ -17,8 +17,7 @@ class PersistQueueConsumer(AbstractConsumer):
|
|
|
17
17
|
while True:
|
|
18
18
|
item = pub.queue.get()
|
|
19
19
|
# self.logger.debug(f'从本地持久化sqlite的 [{self._queue_name}] 队列中 取出的消息是: {item} ')
|
|
20
|
-
|
|
21
|
-
kw = {'body': json.loads(item), 'q': pub.queue, 'item': item}
|
|
20
|
+
kw = {'body': item, 'q': pub.queue, 'item': item}
|
|
22
21
|
self._submit_task(kw)
|
|
23
22
|
|
|
24
23
|
def _confirm_consume(self, kw):
|
|
@@ -53,8 +53,7 @@ class PulsarConsumer(AbstractConsumer, ):
|
|
|
53
53
|
while True:
|
|
54
54
|
msg = self._consumer.receive()
|
|
55
55
|
if msg:
|
|
56
|
-
|
|
57
|
-
kw = {'body': json.loads(msg.data()), 'msg': msg}
|
|
56
|
+
kw = {'body': msg.data(), 'msg': msg}
|
|
58
57
|
self._submit_task(kw)
|
|
59
58
|
|
|
60
59
|
def _confirm_consume(self, kw):
|
|
@@ -21,8 +21,6 @@ class RabbitmqConsumerAmqpStorm(AbstractConsumer):
|
|
|
21
21
|
def callback(amqpstorm_message: amqpstorm.Message):
|
|
22
22
|
body = amqpstorm_message.body
|
|
23
23
|
# self.logger.debug(f'从rabbitmq的 [{self._queue_name}] 队列中 取出的消息是: {body}')
|
|
24
|
-
self._print_message_get_from_broker('rabbitmq', body)
|
|
25
|
-
body = json.loads(body)
|
|
26
24
|
kw = {'amqpstorm_message': amqpstorm_message, 'body': body}
|
|
27
25
|
self._submit_task(kw)
|
|
28
26
|
|
|
@@ -37,8 +37,6 @@ class RabbitmqConsumer(AbstractConsumer):
|
|
|
37
37
|
def callback(ch, method, properties, body):
|
|
38
38
|
body = body.decode()
|
|
39
39
|
# self.logger.debug(f'从rabbitmq的 [{self._queue_name}] 队列中 取出的消息是: {body}')
|
|
40
|
-
self._print_message_get_from_broker('rabbitmq', body)
|
|
41
|
-
body = json.loads(body)
|
|
42
40
|
kw = {'ch': ch, 'method': method, 'properties': properties, 'body': body}
|
|
43
41
|
self._submit_task(kw)
|
|
44
42
|
|
|
@@ -34,7 +34,6 @@ class RabbitmqConsumer(AbstractConsumer):
|
|
|
34
34
|
def callback(ch, method, properties, body):
|
|
35
35
|
body = body.decode()
|
|
36
36
|
self.logger.debug(f'从rabbitmq的 [{self._queue_name}] 队列中 取出的消息是: {body}')
|
|
37
|
-
body = json.loads(body)
|
|
38
37
|
kw = {'ch': ch, 'method': method, 'properties': properties, 'body': body}
|
|
39
38
|
self._submit_task(kw)
|
|
40
39
|
|
|
@@ -23,8 +23,7 @@ class RabbitmqConsumerRabbitpy(AbstractConsumer):
|
|
|
23
23
|
for message in channel.basic_consume(self._queue_name, no_ack=False):
|
|
24
24
|
body = message.body.decode()
|
|
25
25
|
# self.logger.debug(f'从rabbitmq {self._queue_name} 队列中 取出的消息是: {body}')
|
|
26
|
-
|
|
27
|
-
kw = {'message': message, 'body': json.loads(message.body.decode())}
|
|
26
|
+
kw = {'message': message, 'body': body}
|
|
28
27
|
self._submit_task(kw)
|
|
29
28
|
|
|
30
29
|
def _confirm_consume(self, kw):
|
|
@@ -27,9 +27,7 @@ class RedisBrpopLpushConsumer(AbstractConsumer, RedisMixin):
|
|
|
27
27
|
while True:
|
|
28
28
|
msg = self.redis_db_frame.brpoplpush(self._queue_name, unack_list_name, timeout=60)
|
|
29
29
|
if msg:
|
|
30
|
-
|
|
31
|
-
task_dict = json.loads(msg)
|
|
32
|
-
kw = {'body': task_dict, 'raw_msg': msg}
|
|
30
|
+
kw = {'body': msg, 'raw_msg': msg}
|
|
33
31
|
self._submit_task(kw)
|
|
34
32
|
|
|
35
33
|
def _confirm_consume(self, kw):
|
|
@@ -34,17 +34,15 @@ class RedisConsumer(AbstractConsumer, RedisMixin):
|
|
|
34
34
|
task_str_list = p.execute()[0]
|
|
35
35
|
if task_str_list:
|
|
36
36
|
# self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {task_str_list} ')
|
|
37
|
-
self._print_message_get_from_broker(
|
|
37
|
+
self._print_message_get_from_broker( task_str_list)
|
|
38
38
|
for task_str in task_str_list:
|
|
39
|
-
kw = {'body':
|
|
39
|
+
kw = {'body': task_str}
|
|
40
40
|
self._submit_task(kw)
|
|
41
41
|
else:
|
|
42
42
|
result = self.redis_db_frame.brpop(self._queue_name, timeout=60)
|
|
43
43
|
if result:
|
|
44
44
|
# self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {result[1].decode()} ')
|
|
45
|
-
|
|
46
|
-
task_dict = json.loads(result[1])
|
|
47
|
-
kw = {'body': task_dict}
|
|
45
|
+
kw = {'body': result[1]}
|
|
48
46
|
self._submit_task(kw)
|
|
49
47
|
|
|
50
48
|
def _shedual_task00(self):
|
|
@@ -52,9 +50,7 @@ class RedisConsumer(AbstractConsumer, RedisMixin):
|
|
|
52
50
|
result = self.redis_db_frame.blpop(self._queue_name, timeout=60)
|
|
53
51
|
if result:
|
|
54
52
|
# self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {result[1].decode()} ')
|
|
55
|
-
|
|
56
|
-
task_dict = json.loads(result[1])
|
|
57
|
-
kw = {'body': task_dict}
|
|
53
|
+
kw = {'body': result[1]}
|
|
58
54
|
self._submit_task(kw)
|
|
59
55
|
|
|
60
56
|
def _confirm_consume(self, kw):
|
|
@@ -32,9 +32,7 @@ class RedisConsumerAckAble000(ConsumerConfirmMixinWithTheHelpOfRedis, AbstractCo
|
|
|
32
32
|
# 如果运行了第20行,但没运行下面这一行,仍然有极小概率会丢失1个任务。但比不做控制随意关停,丢失几百个线程你的redis任务强多了。
|
|
33
33
|
self._add_task_str_to_unack_zset(task_str, )
|
|
34
34
|
# self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {task_str} ')
|
|
35
|
-
|
|
36
|
-
task_dict = json.loads(task_str)
|
|
37
|
-
kw = {'body': task_dict, 'task_str': task_str}
|
|
35
|
+
kw = {'body': task_str, 'task_str': task_str}
|
|
38
36
|
self._submit_task(kw)
|
|
39
37
|
|
|
40
38
|
def _requeue(self, kw):
|
|
@@ -74,8 +72,7 @@ class RedisConsumerAckAble111(ConsumerConfirmMixinWithTheHelpOfRedis, AbstractCo
|
|
|
74
72
|
if return_v:
|
|
75
73
|
task_str = return_v
|
|
76
74
|
self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {task_str} ')
|
|
77
|
-
|
|
78
|
-
kw = {'body': task_dict, 'task_str': task_str}
|
|
75
|
+
kw = {'body': task_str, 'task_str': task_str}
|
|
79
76
|
self._submit_task(kw)
|
|
80
77
|
else:
|
|
81
78
|
# print('xiuxi')
|
|
@@ -118,8 +115,7 @@ class RedisConsumerAckAble(ConsumerConfirmMixinWithTheHelpOfRedisByHearbeat, Abs
|
|
|
118
115
|
if return_v:
|
|
119
116
|
task_str = return_v
|
|
120
117
|
self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {task_str} ')
|
|
121
|
-
|
|
122
|
-
kw = {'body': task_dict, 'task_str': task_str}
|
|
118
|
+
kw = {'body': task_str, 'task_str': task_str}
|
|
123
119
|
self._submit_task(kw)
|
|
124
120
|
else:
|
|
125
121
|
# print('xiuxi')
|
|
@@ -149,11 +145,10 @@ class RedisConsumerAckAble(ConsumerConfirmMixinWithTheHelpOfRedisByHearbeat, Abs
|
|
|
149
145
|
while True:
|
|
150
146
|
task_str_list = script(keys=[self._queue_name, self._unack_zset_name], args=[time.time()])
|
|
151
147
|
if task_str_list:
|
|
152
|
-
self._print_message_get_from_broker(
|
|
148
|
+
self._print_message_get_from_broker( task_str_list)
|
|
153
149
|
# self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {task_str_list} ')
|
|
154
150
|
for task_str in task_str_list:
|
|
155
|
-
|
|
156
|
-
kw = {'body': task_dict, 'task_str': task_str}
|
|
151
|
+
kw = {'body': task_str, 'task_str': task_str}
|
|
157
152
|
self._submit_task(kw)
|
|
158
153
|
else:
|
|
159
154
|
time.sleep(0.2)
|
|
@@ -60,11 +60,9 @@ class RedisPriorityConsumer(RedisConsumerAckAble):
|
|
|
60
60
|
if task_tuple:
|
|
61
61
|
msg = task_tuple[1]
|
|
62
62
|
self.redis_db_frame.zadd(self._unack_zset_name, {msg: time.time()})
|
|
63
|
-
self.logger.debug(task_tuple)
|
|
64
|
-
self._print_message_get_from_broker('redis', msg)
|
|
63
|
+
# self.logger.debug(task_tuple)
|
|
65
64
|
# self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {task_str_list} ')
|
|
66
|
-
|
|
67
|
-
kw = {'body': task_dict, 'task_str': msg}
|
|
65
|
+
kw = {'body': msg, 'task_str': msg}
|
|
68
66
|
self._submit_task(kw)
|
|
69
67
|
|
|
70
68
|
def _shedual_task(self):
|
|
@@ -87,10 +85,8 @@ class RedisPriorityConsumer(RedisConsumerAckAble):
|
|
|
87
85
|
except redis5.WatchError:
|
|
88
86
|
continue
|
|
89
87
|
if task_tuple:
|
|
90
|
-
self._print_message_get_from_broker('redis', msg)
|
|
91
88
|
# self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {task_str_list} ')
|
|
92
|
-
|
|
93
|
-
kw = {'body': task_dict, 'task_str': msg}
|
|
89
|
+
kw = {'body': msg, 'task_str': msg}
|
|
94
90
|
self._submit_task(kw)
|
|
95
91
|
|
|
96
92
|
def _requeue(self, kw):
|
|
@@ -17,9 +17,8 @@ class RedisConsumer(AbstractConsumer, RedisMixin):
|
|
|
17
17
|
while True:
|
|
18
18
|
result = self.redis_db_frame.blpop(self._queue_name,timeout=60)
|
|
19
19
|
if result:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
kw = {'body': task_dict}
|
|
20
|
+
|
|
21
|
+
kw = {'body': result[1]}
|
|
23
22
|
self._submit_task(kw)
|
|
24
23
|
|
|
25
24
|
def _confirm_consume(self, kw):
|
|
@@ -18,8 +18,8 @@ class RedisPbSubConsumer(AbstractConsumer, RedisMixin):
|
|
|
18
18
|
pub.subscribe(self.queue_name)
|
|
19
19
|
for item in pub.listen():
|
|
20
20
|
if item['type'] == 'message':
|
|
21
|
-
|
|
22
|
-
kw = {'body':
|
|
21
|
+
|
|
22
|
+
kw = {'body': item['data']}
|
|
23
23
|
self._submit_task(kw)
|
|
24
24
|
|
|
25
25
|
def _shedual_task(self):
|
|
@@ -29,7 +29,7 @@ class RedisPbSubConsumer(AbstractConsumer, RedisMixin):
|
|
|
29
29
|
while True: # 无限循环
|
|
30
30
|
msg_list = pub.parse_response(timeout=60) # 得到消息内容
|
|
31
31
|
if msg_list:
|
|
32
|
-
kw = {'body':
|
|
32
|
+
kw = {'body': msg_list[2]}
|
|
33
33
|
self._submit_task(kw)
|
|
34
34
|
|
|
35
35
|
|
|
@@ -44,10 +44,10 @@ class RedisStreamConsumer(AbstractConsumer, RedisMixin):
|
|
|
44
44
|
{self.queue_name: ">"}, count=100, block=60 * 1000)
|
|
45
45
|
if results:
|
|
46
46
|
# self.logger.debug(f'从redis的 [{self._queue_name}] stream 中 取出的消息是: {results} ')
|
|
47
|
-
self._print_message_get_from_broker(
|
|
47
|
+
self._print_message_get_from_broker( results)
|
|
48
48
|
# print(results[0][1])
|
|
49
49
|
for msg_id, msg in results[0][1]:
|
|
50
|
-
kw = {'body':
|
|
50
|
+
kw = {'body': msg[''], 'msg_id': msg_id}
|
|
51
51
|
self._submit_task(kw)
|
|
52
52
|
|
|
53
53
|
def _confirm_consume(self, kw):
|
|
@@ -91,5 +91,5 @@ class RedisStreamConsumer(AbstractConsumer, RedisMixin):
|
|
|
91
91
|
self.logger.warning(f' {self._queue_name} 的分组 {self.group} 的消费者 {self.consumer_identification} 夺取 断开的消费者 {xinfo_item["name"]}'
|
|
92
92
|
f' {len(xclaim_task_list)} 个任务,详细是 {xclaim_task_list} ')
|
|
93
93
|
for task in xclaim_task_list:
|
|
94
|
-
kw = {'body':
|
|
94
|
+
kw = {'body': task[1][''], 'msg_id': task[0]}
|
|
95
95
|
self._submit_task(kw)
|
|
@@ -31,8 +31,8 @@ class RocketmqConsumer(AbstractConsumer):
|
|
|
31
31
|
|
|
32
32
|
def callback(rocketmq_msg):
|
|
33
33
|
# self.logger.debug(f'从rocketmq的 [{self._queue_name}] 主题的queue_id {rocketmq_msg.queue_id} 中 取出的消息是:{rocketmq_msg.body}')
|
|
34
|
-
|
|
35
|
-
kw = {'body':
|
|
34
|
+
|
|
35
|
+
kw = {'body': rocketmq_msg.body, 'rocketmq_msg': rocketmq_msg}
|
|
36
36
|
self._submit_task(kw)
|
|
37
37
|
|
|
38
38
|
consumer.subscribe(self._queue_name, callback)
|
|
@@ -20,7 +20,7 @@ class SqlachemyConsumer(AbstractConsumer):
|
|
|
20
20
|
sqla_task_dict = self.queue.get()
|
|
21
21
|
# self.logger.debug(f'从数据库 {frame_config.SQLACHEMY_ENGINE_URL[:25]}。。 的 [{self._queue_name}] 队列中 取出的消息是: 消息是: {sqla_task_dict}')
|
|
22
22
|
self._print_message_get_from_broker(f'从数据库 {BrokerConnConfig.SQLACHEMY_ENGINE_URL[:25]}', sqla_task_dict)
|
|
23
|
-
kw = {'body':
|
|
23
|
+
kw = {'body': sqla_task_dict['body'], 'sqla_task_dict': sqla_task_dict}
|
|
24
24
|
self._submit_task(kw)
|
|
25
25
|
|
|
26
26
|
def _confirm_consume(self, kw):
|
|
@@ -42,10 +42,10 @@ class TCPConsumer(AbstractConsumer, ):
|
|
|
42
42
|
# print('server收到的数据', data)
|
|
43
43
|
if not data:
|
|
44
44
|
break
|
|
45
|
-
self._print_message_get_from_broker(f'udp {self._ip_port_raw}', data.decode())
|
|
45
|
+
# self._print_message_get_from_broker(f'udp {self._ip_port_raw}', data.decode())
|
|
46
46
|
tcp_cli_sock.send('has_recived'.encode())
|
|
47
47
|
# tcp_cli_sock.close()
|
|
48
|
-
kw = {'body':
|
|
48
|
+
kw = {'body': data}
|
|
49
49
|
self._submit_task(kw)
|
|
50
50
|
tcp_cli_sock.close()
|
|
51
51
|
except ConnectionResetError:
|
|
@@ -22,8 +22,8 @@ class TxtFileConsumer(AbstractConsumer, ):
|
|
|
22
22
|
while True:
|
|
23
23
|
with file_lock:
|
|
24
24
|
item = queue.get()
|
|
25
|
-
|
|
26
|
-
kw = {'body':
|
|
25
|
+
|
|
26
|
+
kw = {'body': item, 'q': queue, 'item': item}
|
|
27
27
|
self._submit_task(kw)
|
|
28
28
|
|
|
29
29
|
def _confirm_consume(self, kw):
|
|
@@ -31,9 +31,9 @@ class UDPConsumer(AbstractConsumer, ):
|
|
|
31
31
|
while True:
|
|
32
32
|
data, client_addr = server.recvfrom(self.BUFSIZE)
|
|
33
33
|
# print('server收到的数据', data)
|
|
34
|
-
self._print_message_get_from_broker(f'udp {ip_port}', data.decode())
|
|
34
|
+
# self._print_message_get_from_broker(f'udp {ip_port}', data.decode())
|
|
35
35
|
server.sendto('has_recived'.encode(), client_addr)
|
|
36
|
-
kw = {'body':
|
|
36
|
+
kw = {'body': data}
|
|
37
37
|
self._submit_task(kw)
|
|
38
38
|
|
|
39
39
|
def _confirm_consume(self, kw):
|
|
@@ -96,8 +96,7 @@ class ZeroMqConsumer(AbstractConsumer):
|
|
|
96
96
|
while True:
|
|
97
97
|
message = zsocket.recv()
|
|
98
98
|
# self.logger.debug(f""" 从 zeromq 取出的消息是 {message}""")
|
|
99
|
-
self.
|
|
100
|
-
self._submit_task({'body': json.loads(message)})
|
|
99
|
+
self._submit_task({'body': message})
|
|
101
100
|
zsocket.send('recv ok'.encode())
|
|
102
101
|
|
|
103
102
|
def _confirm_consume(self, kw):
|
|
@@ -7,7 +7,7 @@ import importlib.util
|
|
|
7
7
|
# import nb_log
|
|
8
8
|
from funboost.core.loggers import FunboostFileLoggerMixin
|
|
9
9
|
from funboost.utils.decorators import flyweight
|
|
10
|
-
from funboost.core.lazy_impoter import
|
|
10
|
+
from funboost.core.lazy_impoter import funboost_lazy_impoter
|
|
11
11
|
|
|
12
12
|
@flyweight
|
|
13
13
|
class BoosterDiscovery(FunboostFileLoggerMixin):
|
|
@@ -68,7 +68,7 @@ class BoosterDiscovery(FunboostFileLoggerMixin):
|
|
|
68
68
|
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
|
69
69
|
module = importlib.util.module_from_spec(spec)
|
|
70
70
|
spec.loader.exec_module(module)
|
|
71
|
-
|
|
71
|
+
funboost_lazy_impoter.BoostersManager.show_all_boosters()
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
if __name__ == '__main__':
|
funboost/core/lazy_impoter.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import abc
|
|
2
2
|
|
|
3
|
-
from funboost.utils.decorators import cached_method_result, singleton, SingletonBaseNew, SingletonBaseCustomInit
|
|
3
|
+
from funboost.utils.decorators import cached_method_result, singleton, SingletonBaseNew, SingletonBaseCustomInit, singleton_no_lock
|
|
4
4
|
|
|
5
5
|
"""
|
|
6
6
|
延迟导入
|
|
@@ -8,7 +8,7 @@ from funboost.utils.decorators import cached_method_result, singleton, Singleton
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class
|
|
11
|
+
class FunboostLazyImpoter(SingletonBaseNew):
|
|
12
12
|
"""
|
|
13
13
|
延迟导入,避免需要互相导入.
|
|
14
14
|
"""
|
|
@@ -26,7 +26,7 @@ class LazyImpoter(SingletonBaseNew):
|
|
|
26
26
|
# return get_current_taskid
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
funboost_lazy_impoter = FunboostLazyImpoter()
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
# noinspection SpellCheckingInspection
|
|
@@ -40,34 +40,19 @@ class GeventImporter:
|
|
|
40
40
|
from gevent.queue import JoinableQueue
|
|
41
41
|
"""
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
@cached_method_result
|
|
45
|
-
def gevent(self):
|
|
43
|
+
def __init__(self):
|
|
46
44
|
import gevent
|
|
47
45
|
print('导入gevent')
|
|
48
|
-
return gevent
|
|
49
|
-
|
|
50
|
-
@property
|
|
51
|
-
@cached_method_result
|
|
52
|
-
def gevent_pool(self):
|
|
53
46
|
from gevent import pool as gevent_pool
|
|
54
|
-
return gevent_pool
|
|
55
|
-
|
|
56
|
-
@property
|
|
57
|
-
@cached_method_result
|
|
58
|
-
def monkey(self):
|
|
59
47
|
from gevent import monkey
|
|
60
|
-
print('导入gevent')
|
|
61
|
-
return monkey
|
|
62
|
-
|
|
63
|
-
@property
|
|
64
|
-
@cached_method_result
|
|
65
|
-
def JoinableQueue(self):
|
|
66
48
|
from gevent.queue import JoinableQueue
|
|
67
|
-
|
|
49
|
+
self.gevent = gevent
|
|
50
|
+
self.gevent_pool = gevent_pool
|
|
51
|
+
self.monkey = monkey
|
|
52
|
+
self.JoinableQueue = JoinableQueue
|
|
68
53
|
|
|
69
54
|
|
|
70
|
-
@
|
|
55
|
+
@singleton_no_lock
|
|
71
56
|
class EventletImporter:
|
|
72
57
|
"""
|
|
73
58
|
避免提前导入
|
|
@@ -83,7 +68,7 @@ class EventletImporter:
|
|
|
83
68
|
self.Timeout = Timeout
|
|
84
69
|
|
|
85
70
|
|
|
86
|
-
@
|
|
71
|
+
@singleton_no_lock
|
|
87
72
|
class PeeweeImporter:
|
|
88
73
|
def __init__(self):
|
|
89
74
|
"""pip install peewee == 3.17"""
|
|
@@ -99,7 +84,7 @@ class PeeweeImporter:
|
|
|
99
84
|
self.dict_to_model = dict_to_model
|
|
100
85
|
|
|
101
86
|
|
|
102
|
-
@
|
|
87
|
+
@singleton_no_lock
|
|
103
88
|
class AioHttpImporter:
|
|
104
89
|
|
|
105
90
|
def __init__(self):
|
|
@@ -110,7 +95,7 @@ class AioHttpImporter:
|
|
|
110
95
|
self.Request = Request
|
|
111
96
|
|
|
112
97
|
|
|
113
|
-
@
|
|
98
|
+
@singleton_no_lock
|
|
114
99
|
class NatsImporter:
|
|
115
100
|
def __init__(self):
|
|
116
101
|
"""pip install nats-python """
|
|
@@ -118,7 +103,8 @@ class NatsImporter:
|
|
|
118
103
|
self.NATSClient = NATSClient
|
|
119
104
|
self.NATSMessage = NATSMessage
|
|
120
105
|
|
|
121
|
-
|
|
106
|
+
|
|
107
|
+
@singleton_no_lock
|
|
122
108
|
class GnsqImporter:
|
|
123
109
|
def __init__(self):
|
|
124
110
|
"""pip install gnsq==1.0.1"""
|
|
@@ -131,7 +117,8 @@ class GnsqImporter:
|
|
|
131
117
|
self.NsqdHTTPClient = NsqdHTTPClient
|
|
132
118
|
self.NSQHttpError = NSQHttpError
|
|
133
119
|
|
|
134
|
-
|
|
120
|
+
|
|
121
|
+
@singleton_no_lock
|
|
135
122
|
class ElasticsearchImporter:
|
|
136
123
|
def __init__(self):
|
|
137
124
|
"""pip install elasticsearch """
|
|
@@ -139,28 +126,31 @@ class ElasticsearchImporter:
|
|
|
139
126
|
self.helpers = helpers
|
|
140
127
|
|
|
141
128
|
|
|
142
|
-
@
|
|
129
|
+
@singleton_no_lock
|
|
143
130
|
class PsutilImporter:
|
|
144
131
|
def __init__(self):
|
|
145
132
|
"""pip install psutil"""
|
|
146
133
|
import psutil
|
|
147
134
|
self.psutil = psutil
|
|
148
135
|
|
|
149
|
-
|
|
136
|
+
|
|
137
|
+
@singleton_no_lock
|
|
150
138
|
class PahoMqttImporter:
|
|
151
139
|
def __init__(self):
|
|
152
140
|
"""pip install paho-mqtt"""
|
|
153
141
|
import paho.mqtt.client as mqtt
|
|
154
142
|
self.mqtt = mqtt
|
|
155
143
|
|
|
156
|
-
|
|
144
|
+
|
|
145
|
+
@singleton_no_lock
|
|
157
146
|
class ZmqImporter:
|
|
158
147
|
def __init__(self):
|
|
159
148
|
"""pip install zmq pyzmq"""
|
|
160
149
|
import zmq
|
|
161
150
|
self.zmq = zmq
|
|
162
151
|
|
|
163
|
-
|
|
152
|
+
|
|
153
|
+
@singleton_no_lock
|
|
164
154
|
class KafkaPythonImporter:
|
|
165
155
|
def __init__(self):
|
|
166
156
|
"""pip install kafka-python==2.0.2"""
|
|
@@ -177,7 +167,10 @@ class KafkaPythonImporter:
|
|
|
177
167
|
|
|
178
168
|
|
|
179
169
|
if __name__ == '__main__':
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
170
|
+
print()
|
|
171
|
+
for i in range(10000000):
|
|
172
|
+
# funboost_lazy_impoter.BoostersManager
|
|
173
|
+
# EventletImporter().greenpool
|
|
174
|
+
# GeventImporter().JoinableQueue
|
|
175
|
+
ZmqImporter().zmq
|
|
176
|
+
print()
|
|
@@ -7,11 +7,11 @@ from concurrent.futures import ProcessPoolExecutor
|
|
|
7
7
|
from funboost.core.booster import Booster
|
|
8
8
|
from funboost.core.helper_funs import run_forever
|
|
9
9
|
from funboost.core.loggers import flogger
|
|
10
|
-
from funboost.core.lazy_impoter import
|
|
10
|
+
from funboost.core.lazy_impoter import funboost_lazy_impoter
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def _run_consumer_in_new_process(queue_name, ):
|
|
14
|
-
booster_current_pid =
|
|
14
|
+
booster_current_pid = funboost_lazy_impoter.BoostersManager.get_or_create_booster_by_queue_name(queue_name)
|
|
15
15
|
# booster_current_pid = boost(**boost_params)(consuming_function)
|
|
16
16
|
booster_current_pid.consume()
|
|
17
17
|
# ConsumersManager.join_all_consumer_shedual_task_thread()
|
|
@@ -49,7 +49,7 @@ def run_consumer_with_multi_process(booster: Booster, process_num=1):
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
def _multi_process_pub_params_list_in_new_process(queue_name, msgs: List[dict]):
|
|
52
|
-
booster_current_pid =
|
|
52
|
+
booster_current_pid = funboost_lazy_impoter.BoostersManager.get_or_create_booster_by_queue_name(queue_name)
|
|
53
53
|
publisher = booster_current_pid.publisher
|
|
54
54
|
publisher.set_log_level(20) # 超高速发布,如果打印详细debug日志会卡死屏幕和严重降低代码速度。
|
|
55
55
|
for msg in msgs:
|
funboost/utils/decorators.py
CHANGED
|
@@ -164,6 +164,20 @@ def singleton(cls:ClSX) -> ClSX:
|
|
|
164
164
|
|
|
165
165
|
return _singleton
|
|
166
166
|
|
|
167
|
+
def singleton_no_lock(cls:ClSX) -> ClSX:
|
|
168
|
+
"""
|
|
169
|
+
单例模式装饰器,新加入线程锁,更牢固的单例模式,主要解决多线程如100线程同时实例化情况下可能会出现三例四例的情况,实测。
|
|
170
|
+
"""
|
|
171
|
+
_instance = {}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
@wraps(cls)
|
|
175
|
+
def _singleton(*args, **kwargs):
|
|
176
|
+
if cls not in _instance:
|
|
177
|
+
_instance[cls] = cls(*args, **kwargs)
|
|
178
|
+
return _instance[cls]
|
|
179
|
+
|
|
180
|
+
return _singleton
|
|
167
181
|
|
|
168
182
|
class SingletonMeta(type):
|
|
169
183
|
_instances = {}
|
funboost/utils/paramiko_util.py
CHANGED
|
@@ -50,7 +50,7 @@ class ParamikoFolderUploader(LoggerMixin, LoggerLevelSetterMixin):
|
|
|
50
50
|
|
|
51
51
|
t = paramiko.Transport((host, port))
|
|
52
52
|
if pkey_file_path is not None and os.path.exists(pkey_file_path):
|
|
53
|
-
pkey = paramiko.RSAKey.from_private_key_file(
|
|
53
|
+
pkey = paramiko.RSAKey.from_private_key_file(pkey_file_path)
|
|
54
54
|
t.connect(username=user, pkey=pkey)
|
|
55
55
|
else:
|
|
56
56
|
t.connect(username=user, password=password)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: funboost
|
|
3
|
-
Version: 44.
|
|
3
|
+
Version: 44.3
|
|
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=b-Q73uFd54nOxWGxbbK2f3PCjTtwXTLbJuMZgOPr4p8,3834
|
|
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,46 +33,46 @@ 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=e68jt2P4F8sB_YrNMQML9k_0uqSc727qZZSLAkN5uQs,76496
|
|
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
|
|
40
|
-
funboost/consumers/http_consumer.py,sha256=
|
|
41
|
-
funboost/consumers/http_consumer000.py,sha256=
|
|
42
|
-
funboost/consumers/httpsqs_consumer.py,sha256=
|
|
40
|
+
funboost/consumers/http_consumer.py,sha256=2MVqEzHW9qIKWvgIQS7VncGfvpmWhQ3BWWjfyHWC-as,2179
|
|
41
|
+
funboost/consumers/http_consumer000.py,sha256=PiiSLSQB-hHgS1vAn8DoHD2siC3zO6_kKjVW0g6AFIc,4379
|
|
42
|
+
funboost/consumers/httpsqs_consumer.py,sha256=kaqOcrKMLrSR27XqeiheRDmpF1KDVDghgbHcefTjqt8,1171
|
|
43
43
|
funboost/consumers/huey_consumer.py,sha256=cW10ZPxdZQzUuJwdqQpJIRPTj2vCbZS0uXFJ7L8bpa4,1843
|
|
44
|
-
funboost/consumers/kafka_consumer.py,sha256=
|
|
45
|
-
funboost/consumers/kafka_consumer_manually_commit.py,sha256=
|
|
46
|
-
funboost/consumers/kombu_consumer.py,sha256=
|
|
47
|
-
funboost/consumers/local_python_queue_consumer.py,sha256=
|
|
48
|
-
funboost/consumers/memory_deque_consumer.py,sha256=
|
|
49
|
-
funboost/consumers/mongomq_consumer.py,sha256=
|
|
50
|
-
funboost/consumers/mqtt_consumer.py,sha256=
|
|
44
|
+
funboost/consumers/kafka_consumer.py,sha256=OAq6fclhDBufsWTowAikGBYjptc28SIE-EDzFEz9J-I,4324
|
|
45
|
+
funboost/consumers/kafka_consumer_manually_commit.py,sha256=kkHyTf4EQFEEoyiZ-pZQBR-g3M1rkFYnfKFXoeODCIE,9620
|
|
46
|
+
funboost/consumers/kombu_consumer.py,sha256=hj2J-1r5hBbcTNXIpU6qe1MwYPD-8gEKlDTSRV3B5Js,10208
|
|
47
|
+
funboost/consumers/local_python_queue_consumer.py,sha256=HyUFZXY6phF6eaL1qd5z7Kof3LZ0J6EO0zllBS-skqA,1220
|
|
48
|
+
funboost/consumers/memory_deque_consumer.py,sha256=tTwOkrB9GdySOQstVLnU4hnBnap6rafCeoXhmV0TI5c,1110
|
|
49
|
+
funboost/consumers/mongomq_consumer.py,sha256=e1Cupe-Cb2LUuJlQhER6NecrvK7FyzKKZ2HxyfOI-OY,1119
|
|
50
|
+
funboost/consumers/mqtt_consumer.py,sha256=iLWKxe0CjKHUYrE6YMWNJHto0tD3siUAvZl9ssNsz_s,2297
|
|
51
51
|
funboost/consumers/nameko_consumer.py,sha256=Qhl2FmrIjzjXLkIdMLQdhZ8GmrhiuoEss7cwGHCFT7c,2213
|
|
52
|
-
funboost/consumers/nats_consumer.py,sha256=
|
|
53
|
-
funboost/consumers/nsq_consumer.py,sha256=
|
|
54
|
-
funboost/consumers/peewee_conusmer.py,sha256=
|
|
55
|
-
funboost/consumers/persist_queue_consumer.py,sha256=
|
|
56
|
-
funboost/consumers/pulsar_consumer.py,sha256=
|
|
57
|
-
funboost/consumers/rabbitmq_amqpstorm_consumer.py,sha256=
|
|
58
|
-
funboost/consumers/rabbitmq_pika_consumer.py,sha256=
|
|
59
|
-
funboost/consumers/rabbitmq_pika_consumerv0.py,sha256=
|
|
60
|
-
funboost/consumers/rabbitmq_rabbitpy_consumer.py,sha256=
|
|
61
|
-
funboost/consumers/redis_brpoplpush_consumer.py,sha256=
|
|
62
|
-
funboost/consumers/redis_consumer.py,sha256=
|
|
63
|
-
funboost/consumers/redis_consumer_ack_able.py,sha256=
|
|
64
|
-
funboost/consumers/redis_consumer_priority.py,sha256=
|
|
65
|
-
funboost/consumers/redis_consumer_simple.py,sha256=
|
|
52
|
+
funboost/consumers/nats_consumer.py,sha256=yv_8SC4zdw5UXBpYooFMXHaC-mNzws5IK0woxHWr1NM,1119
|
|
53
|
+
funboost/consumers/nsq_consumer.py,sha256=KcP4wT656LyvuwyQXnVp0B6DwYvnZ6z_Vyzt0KjHAQc,1518
|
|
54
|
+
funboost/consumers/peewee_conusmer.py,sha256=VqbSu9AdKO4_wgu0XhTWRO3VeWctecbbz2X_V04_kXw,1115
|
|
55
|
+
funboost/consumers/persist_queue_consumer.py,sha256=PUfelfW84YiqcsbcIAveWMC50rw2DScZ3u_aiaS0Kk8,1015
|
|
56
|
+
funboost/consumers/pulsar_consumer.py,sha256=eorN61kCvP3yg4fNAB3ZCfqpJJxPnAN6PJY48uiYX5Y,2385
|
|
57
|
+
funboost/consumers/rabbitmq_amqpstorm_consumer.py,sha256=r6pQP14c9-D1Bn2hc5hHoHqHOgWJaB2itiemEhz4iIM,2214
|
|
58
|
+
funboost/consumers/rabbitmq_pika_consumer.py,sha256=51IkRUSR0v2v7BUlA8oInx81VGeO5OaD2pk0UXHdY78,5408
|
|
59
|
+
funboost/consumers/rabbitmq_pika_consumerv0.py,sha256=rIQToBTBqGdjnzMhg0vyZMY87NtK_Uw8ggiTu39JQ_w,4777
|
|
60
|
+
funboost/consumers/rabbitmq_rabbitpy_consumer.py,sha256=xxINY037pmgF3_lJA-zhf9qUIUx6DdqC7tsUOQL3dL4,1330
|
|
61
|
+
funboost/consumers/redis_brpoplpush_consumer.py,sha256=HqjgjjEibq7D-5XFpJtyaPvtfXD5zbq9cjSHx4aM1gU,2952
|
|
62
|
+
funboost/consumers/redis_consumer.py,sha256=63QbUfEftr29XNG7989UgLWM9Adn01A5gPiBMMGQc0w,2559
|
|
63
|
+
funboost/consumers/redis_consumer_ack_able.py,sha256=e83pwbxYKdXfD-suUh_5uTQwomBB2-FU0xo_iRvLKFo,7221
|
|
64
|
+
funboost/consumers/redis_consumer_priority.py,sha256=C-ftnlGPPoB7YV3GvwLu9POVGDn_GKlBqO6NlsZ-hdY,5566
|
|
65
|
+
funboost/consumers/redis_consumer_simple.py,sha256=0iGaZpTOwbmbz3PkpUjy-PmsN1PmAFweA-LACv1TyZU,806
|
|
66
66
|
funboost/consumers/redis_filter.py,sha256=rKNFz8mxVo4n4o8v3MP4UqdPAtoK7msQ-1xRgzFfts0,7290
|
|
67
|
-
funboost/consumers/redis_pubsub_consumer.py,sha256=
|
|
68
|
-
funboost/consumers/redis_stream_consumer.py,sha256=
|
|
69
|
-
funboost/consumers/rocketmq_consumer.py,sha256=
|
|
67
|
+
funboost/consumers/redis_pubsub_consumer.py,sha256=8V8EqobKpEXzpsQx_H3A-JBKLsWOsE0n16g62tUMMYY,1122
|
|
68
|
+
funboost/consumers/redis_stream_consumer.py,sha256=xRfrtpCHxBpPHSto1mu3URN7IivX3klFgQM8IxC5tqs,6396
|
|
69
|
+
funboost/consumers/rocketmq_consumer.py,sha256=23KLRz8iO9e_x7asrceRJYhwJFMruUgmKw7m3pHVkw0,1692
|
|
70
70
|
funboost/consumers/rq_consumer.py,sha256=JX84k6Jiv4pBiQMmnhdJ7s7Qz4ub5TWS4T7qTF-WdlM,876
|
|
71
|
-
funboost/consumers/sqlachemy_consumer.py,sha256=
|
|
72
|
-
funboost/consumers/tcp_consumer.py,sha256=
|
|
73
|
-
funboost/consumers/txt_file_consumer.py,sha256=
|
|
74
|
-
funboost/consumers/udp_consumer.py,sha256=
|
|
75
|
-
funboost/consumers/zeromq_consumer.py,sha256=
|
|
71
|
+
funboost/consumers/sqlachemy_consumer.py,sha256=PawUaNV7EZWBQVWXkGaXy1Z16hUgxU4BLDeUFR83ewM,1300
|
|
72
|
+
funboost/consumers/tcp_consumer.py,sha256=9uXzbkgEU-r4kH07v4ASxUSTe-JEo-EgJ1228pju4W4,2035
|
|
73
|
+
funboost/consumers/txt_file_consumer.py,sha256=Uelk6q8hYPudofJXMTaCmg_td7z7HAcZGdoqgRgolOs,1261
|
|
74
|
+
funboost/consumers/udp_consumer.py,sha256=l1ll7RL87KK-L1F_DLZccO2ghxFsZtbWUJVXAOCQUx8,1633
|
|
75
|
+
funboost/consumers/zeromq_consumer.py,sha256=2ZAdo01k7EVZN38Eb9CWCd2hepqLM9YHE1qVBxnCPok,4346
|
|
76
76
|
funboost/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
77
77
|
funboost/contrib/api_publish_msg.py,sha256=8khUiOjbiaTuNlOU4_FMBYYNLkwHssPw-vnlE0iixVk,2480
|
|
78
78
|
funboost/contrib/django_db_deco.py,sha256=RJaRUYdVqS10gWqM4Ncs0Lngox52SUaqIIn5GK5a8Uo,865
|
|
@@ -92,13 +92,13 @@ funboost/core/function_result_status_config.py,sha256=PyjqAQOiwsLt28sRtH-eYRjiI3
|
|
|
92
92
|
funboost/core/function_result_status_saver.py,sha256=UdokGSwU630t70AZnT9Ecj7GpYXORBDivlc9kadoI2E,9172
|
|
93
93
|
funboost/core/helper_funs.py,sha256=m8OJVJ_U_Wp0roHYrKIrHnihcVzTM8jactGx8m6JdfA,1972
|
|
94
94
|
funboost/core/kill_remote_task.py,sha256=MZ5vWLGt6SxyN76h5Lf_id9tyVUzjR-qXNyJwXaGlZY,8129
|
|
95
|
-
funboost/core/lazy_impoter.py,sha256=
|
|
95
|
+
funboost/core/lazy_impoter.py,sha256=ikg6g0yJihhx60d9WpRUEzzHOTJRAmmyjrViC06tv3s,4826
|
|
96
96
|
funboost/core/loggers.py,sha256=63GtTPocskAW5tvQSUJzGEEUZ4Gs1kznLs7Tn0H5zAQ,2418
|
|
97
97
|
funboost/core/msg_result_getter.py,sha256=oZDuLDR5XQNzzvgDTsA7wroICToPwrkU9-OAaXXUQSk,8031
|
|
98
|
-
funboost/core/muliti_process_enhance.py,sha256=
|
|
98
|
+
funboost/core/muliti_process_enhance.py,sha256=tI3178inc5sqPh-jQc0XaTuUD1diIZyHuukBRk1Gp6Y,3595
|
|
99
99
|
funboost/core/task_id_logger.py,sha256=lR19HQcX6Pp8laURCD656xNpF_JP6nLB3zUKI69EWzE,864
|
|
100
100
|
funboost/core/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
101
|
-
funboost/core/cli/discovery_boosters.py,sha256=
|
|
101
|
+
funboost/core/cli/discovery_boosters.py,sha256=mbEyv0bUIGcmgkfXLI_Q1IK1QvVwKyro8XccuuMEA6o,3944
|
|
102
102
|
funboost/core/cli/funboost_cli_user_templ.py,sha256=XUpKLxRKtYfebPUM8wii64kB0HW8L7j9LnRpT0xCfQI,2243
|
|
103
103
|
funboost/core/cli/funboost_fire.py,sha256=OT0SNi9Zb0Tom2E0cWuArQs0obUowAA_rpCF7GdaKPs,5065
|
|
104
104
|
funboost/factories/__init__.py,sha256=s7kKKjR1HU5eMjPD6r5b-SXTVMo1zBp2JjOAtkyt5Yo,178
|
|
@@ -172,7 +172,7 @@ funboost/utils/block_exit.py,sha256=BnfxNYo3lnmhk686RAEoc4u3D4RU_iEMMMgu5L8gIuI,
|
|
|
172
172
|
funboost/utils/bulk_operation.py,sha256=B4FBxlz5f4oqlKDWqer7axn4gnDSfsYoMW2zSUCnGcQ,10101
|
|
173
173
|
funboost/utils/ctrl_c_end.py,sha256=FgT9An-qsUA5gW-V-UKWqOh5shC7C_uvTFn0fS7i8GI,439
|
|
174
174
|
funboost/utils/custom_pysnooper.py,sha256=7yXLKEMY_JjPRRt0Y0N-wV2CFhILlYNh40Y6uRBUaj8,5923
|
|
175
|
-
funboost/utils/decorators.py,sha256=
|
|
175
|
+
funboost/utils/decorators.py,sha256=MaoftkcBXLqRNX8KPik7K2jK5p6Brx2QfPitNaJQCm0,26541
|
|
176
176
|
funboost/utils/develop_log.py,sha256=Wsx0ongGjTit5xqgk1BztYlVEkC6d0-Y7GENXLedVqY,271
|
|
177
177
|
funboost/utils/expire_lock.py,sha256=AOkd1KlvZeIwQaz8ZoKxLpGxWgqQ4mfNHcFphh04o8Q,4732
|
|
178
178
|
funboost/utils/json_helper.py,sha256=HDdtLyZBGpWbUm7vmTypKXd8K-Hb-9BaxpdmRlKMYUI,1849
|
|
@@ -180,7 +180,7 @@ funboost/utils/mongo_util.py,sha256=g2AdsanKm2v9X-OaTCS6hx_0JvRw5WukXIttN3TD9sI,
|
|
|
180
180
|
funboost/utils/monkey_color_log.py,sha256=QChhQMTB6phZ2eBaPq-9tFZF1n7pWeJgmJPIB_ugkvs,7367
|
|
181
181
|
funboost/utils/monkey_patches.py,sha256=vGmtPuTwNLbS8T3gpufSC_cD8_Vnp85roZrCpJZUSE4,2890
|
|
182
182
|
funboost/utils/mqtt_util.py,sha256=BfCmyYwI-B8VL9499_IuYlJDCbv6ZhwyWThMf8dANOU,3199
|
|
183
|
-
funboost/utils/paramiko_util.py,sha256=
|
|
183
|
+
funboost/utils/paramiko_util.py,sha256=rHJm9Cp1YX24ew3jT5iR0qPqv-WJLd7VhRoMkHphY60,5244
|
|
184
184
|
funboost/utils/rabbitmq_factory.py,sha256=ifDCn2RxSGL4MccmktJc5FYQhAcboCgHBlEo3WGpq3g,2910
|
|
185
185
|
funboost/utils/redis_manager.py,sha256=iG3e9k3oedtKcGwDnjKA0hUFsk_MSlvVM2C3m3K97Y4,3657
|
|
186
186
|
funboost/utils/redis_manager_old.py,sha256=c3RBXN6dM3kjVBqkCdotpZuYmFs4d9emfp5iJgC61Us,5516
|
|
@@ -265,9 +265,9 @@ funboost/utils/pysnooper_ydf/utils.py,sha256=evSmGi_Oul7vSP47AJ0DLjFwoCYCfunJZ1m
|
|
|
265
265
|
funboost/utils/pysnooper_ydf/variables.py,sha256=QejRDESBA06KG9OH4sBT4J1M55eaU29EIHg8K_igaXo,3693
|
|
266
266
|
funboost/utils/times/__init__.py,sha256=Y4bQD3SIA_E7W2YvHq2Qdi0dGM4H2DxyFNdDOuFOq1w,2417
|
|
267
267
|
funboost/utils/times/version.py,sha256=11XfnZVVzOgIhXXdeN_mYfdXThfrsbQHpA0wCjz-hpg,17
|
|
268
|
-
funboost-44.
|
|
269
|
-
funboost-44.
|
|
270
|
-
funboost-44.
|
|
271
|
-
funboost-44.
|
|
272
|
-
funboost-44.
|
|
273
|
-
funboost-44.
|
|
268
|
+
funboost-44.3.dist-info/LICENSE,sha256=9EPP2ktG_lAPB8PjmWV-c9BiaJHc_FP6pPLcUrUwx0E,11562
|
|
269
|
+
funboost-44.3.dist-info/METADATA,sha256=xBG1vtA6ZsyfQGXqXTN9wpgIRDsiIKIl5g8zlbyRk0Y,31351
|
|
270
|
+
funboost-44.3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
271
|
+
funboost-44.3.dist-info/entry_points.txt,sha256=BQMqRALuw-QT9x2d7puWaUHriXfy3wIzvfzF61AnSSI,97
|
|
272
|
+
funboost-44.3.dist-info/top_level.txt,sha256=K8WuKnS6MRcEWxP1NvbmCeujJq6TEfbsB150YROlRw0,9
|
|
273
|
+
funboost-44.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|