funboost 19.0__py3-none-any.whl → 19.2__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/consumers/base_consumer.py +7 -4
- funboost/function_result_web/functions.py +5 -1
- funboost/publishers/mongomq_publisher.py +22 -7
- funboost/utils/mongo_util.py +11 -1
- {funboost-19.0.dist-info → funboost-19.2.dist-info}/METADATA +1 -1
- {funboost-19.0.dist-info → funboost-19.2.dist-info}/RECORD +9 -9
- {funboost-19.0.dist-info → funboost-19.2.dist-info}/LICENSE +0 -0
- {funboost-19.0.dist-info → funboost-19.2.dist-info}/WHEEL +0 -0
- {funboost-19.0.dist-info → funboost-19.2.dist-info}/top_level.txt +0 -0
|
@@ -174,8 +174,9 @@ class ResultPersistenceHelper(MongoMixin, LoggerMixin):
|
|
|
174
174
|
self._bulk_list_lock = Lock()
|
|
175
175
|
self._last_bulk_insert_time = 0
|
|
176
176
|
self._has_start_bulk_insert_thread = False
|
|
177
|
+
self._queue_name = queue_name
|
|
177
178
|
if self.function_result_status_persistance_conf.is_save_status:
|
|
178
|
-
task_status_col = self.
|
|
179
|
+
task_status_col = self.get_mongo_collection('task_status', queue_name)
|
|
179
180
|
try:
|
|
180
181
|
# params_str 如果很长,必须使用TEXt或HASHED索引。
|
|
181
182
|
task_status_col.create_indexes([IndexModel([("insert_time_str", -1)]), IndexModel([("insert_time", -1)]),
|
|
@@ -186,11 +187,11 @@ class ResultPersistenceHelper(MongoMixin, LoggerMixin):
|
|
|
186
187
|
except pymongo.errors.OperationFailure as e: # 新的mongo服务端,每次启动重复创建已存在索引会报错,try一下。
|
|
187
188
|
self.logger.warning(e)
|
|
188
189
|
# self._mongo_bulk_write_helper = MongoBulkWriteHelper(task_status_col, 100, 2)
|
|
189
|
-
self.task_status_col = task_status_col
|
|
190
190
|
self.logger.info(f"函数运行状态结果将保存至mongo的 task_status 库的 {queue_name} 集合中,请确认 funboost.py文件中配置的 MONGO_CONNECT_URL")
|
|
191
191
|
|
|
192
192
|
def save_function_result_to_mongo(self, function_result_status: FunctionResultStatus):
|
|
193
193
|
if self.function_result_status_persistance_conf.is_save_status:
|
|
194
|
+
task_status_col = self.get_mongo_collection('task_status', self._queue_name)
|
|
194
195
|
item = function_result_status.get_status_dict()
|
|
195
196
|
item2 = copy.copy(item)
|
|
196
197
|
if not self.function_result_status_persistance_conf.is_save_result:
|
|
@@ -213,12 +214,13 @@ class ResultPersistenceHelper(MongoMixin, LoggerMixin):
|
|
|
213
214
|
daemon=False)(self._bulk_insert)()
|
|
214
215
|
self.logger.warning(f'启动批量保存函数消费状态 结果到mongo的 线程')
|
|
215
216
|
else:
|
|
216
|
-
|
|
217
|
+
task_status_col.insert_one(item2) # 立即实时插入。
|
|
217
218
|
|
|
218
219
|
def _bulk_insert(self):
|
|
219
220
|
with self._bulk_list_lock:
|
|
220
221
|
if time.time() - self._last_bulk_insert_time > 0.5 and self._bulk_list:
|
|
221
|
-
self.
|
|
222
|
+
task_status_col = self.get_mongo_collection('task_status', self._queue_name)
|
|
223
|
+
task_status_col.bulk_write(self._bulk_list, ordered=False)
|
|
222
224
|
self._bulk_list.clear()
|
|
223
225
|
self._last_bulk_insert_time = time.time()
|
|
224
226
|
|
|
@@ -794,6 +796,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
|
|
|
794
796
|
json.dumps(current_function_result_status.get_status_dict(without_datetime_obj=True)))
|
|
795
797
|
p.expire(kw['body']['extra']['task_id'], 600)
|
|
796
798
|
p.execute()
|
|
799
|
+
|
|
797
800
|
if (current_function_result_status.success is False and current_retry_times == max_retry_times) or current_function_result_status.success is True:
|
|
798
801
|
await simple_run_in_executor(push_result)
|
|
799
802
|
|
|
@@ -15,7 +15,7 @@ from funboost.utils.mongo_util import MongoMixin
|
|
|
15
15
|
#
|
|
16
16
|
# do_patch_frame_config()
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
# print(db)
|
|
@@ -23,6 +23,7 @@ db = MongoMixin().mongo_db_task_status
|
|
|
23
23
|
# print(db.list_collection_names())
|
|
24
24
|
|
|
25
25
|
def get_cols(col_name_search: str):
|
|
26
|
+
db = MongoMixin().mongo_db_task_status
|
|
26
27
|
if not col_name_search:
|
|
27
28
|
collection_name_list = db.list_collection_names()
|
|
28
29
|
else:
|
|
@@ -35,6 +36,7 @@ def get_cols(col_name_search: str):
|
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
def query_result(col_name, start_time, end_time, is_success, function_params: str, page, ):
|
|
39
|
+
db = MongoMixin().mongo_db_task_status
|
|
38
40
|
condition = {
|
|
39
41
|
'insert_time': {'$gt': time_util.DatetimeConverter(start_time).datetime_obj,
|
|
40
42
|
'$lt': time_util.DatetimeConverter(end_time).datetime_obj},
|
|
@@ -59,6 +61,7 @@ def query_result(col_name, start_time, end_time, is_success, function_params: st
|
|
|
59
61
|
|
|
60
62
|
|
|
61
63
|
def get_speed(col_name, start_time, end_time):
|
|
64
|
+
db = MongoMixin().mongo_db_task_status
|
|
62
65
|
condition = {
|
|
63
66
|
'insert_time': {'$gt': time_util.DatetimeConverter(start_time).datetime_obj,
|
|
64
67
|
'$lt': time_util.DatetimeConverter(end_time).datetime_obj},
|
|
@@ -78,6 +81,7 @@ def get_speed(col_name, start_time, end_time):
|
|
|
78
81
|
|
|
79
82
|
class Statistic(LoggerMixin):
|
|
80
83
|
def __init__(self, col_name):
|
|
84
|
+
db = MongoMixin().mongo_db_task_status
|
|
81
85
|
self.col = db.get_collection(col_name)
|
|
82
86
|
self.result = {'recent_10_days': {'time_arr': [], 'count_arr': []},
|
|
83
87
|
'recent_24_hours': {'time_arr': [], 'count_arr': []},
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# @Author : ydf
|
|
3
3
|
# @Time : 2022/8/8 0008 12:23
|
|
4
|
+
import os
|
|
5
|
+
|
|
4
6
|
import json
|
|
5
7
|
from funboost.utils.dependency_packages.mongomq import MongoQueue
|
|
6
8
|
from funboost.publishers.base_publisher import AbstractPublisher
|
|
@@ -11,13 +13,26 @@ from funboost.utils.mongo_util import MongoMixin
|
|
|
11
13
|
class MongoMqPublisher(AbstractPublisher, MongoMixin):
|
|
12
14
|
# 使用mongo-queue包实现的基于mongodb的队列。 队列是一个col,自动存放在consume_queues库中。
|
|
13
15
|
# noinspection PyAttributeOutsideInit
|
|
16
|
+
|
|
17
|
+
pid__queue_map = {}
|
|
18
|
+
|
|
14
19
|
def custom_init(self):
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def queue(self):
|
|
24
|
+
''' 不能提前实例化,mongo fork进程不安全,这样是动态生成queue'''
|
|
25
|
+
pid = os.getpid()
|
|
26
|
+
if pid not in MongoMqPublisher.pid__queue_map:
|
|
27
|
+
queuex = MongoQueue(
|
|
28
|
+
# self.mongo_client.get_database('consume_queues').get_collection(self._queue_name),
|
|
29
|
+
self.get_mongo_collection('consume_queues', self._queue_name),
|
|
30
|
+
consumer_id=f"consumer-{time_util.DatetimeConverter().datetime_str}",
|
|
31
|
+
timeout=600,
|
|
32
|
+
max_attempts=3,
|
|
33
|
+
ttl=24 * 3600 * 365)
|
|
34
|
+
MongoMqPublisher.pid__queue_map[pid] =queuex
|
|
35
|
+
return MongoMqPublisher.pid__queue_map[pid]
|
|
21
36
|
|
|
22
37
|
def concrete_realization_of_publish(self, msg):
|
|
23
38
|
# noinspection PyTypeChecker
|
|
@@ -29,7 +44,7 @@ class MongoMqPublisher(AbstractPublisher, MongoMixin):
|
|
|
29
44
|
|
|
30
45
|
def get_message_count(self):
|
|
31
46
|
# return self.queue.size()
|
|
32
|
-
return self.queue.collection.count_documents({'status':'queued'})
|
|
47
|
+
return self.queue.collection.count_documents({'status': 'queued'})
|
|
33
48
|
|
|
34
49
|
def close(self):
|
|
35
50
|
pass
|
funboost/utils/mongo_util.py
CHANGED
|
@@ -36,9 +36,10 @@ class MongoMixin:
|
|
|
36
36
|
"""
|
|
37
37
|
processid__client_map = {}
|
|
38
38
|
processid__db_map = {}
|
|
39
|
+
processid__col_map = {}
|
|
39
40
|
|
|
40
41
|
@property
|
|
41
|
-
def mongo_client(self):
|
|
42
|
+
def mongo_client(self) -> pymongo.MongoClient:
|
|
42
43
|
pid = os.getpid()
|
|
43
44
|
if pid not in MongoMixin.processid__client_map:
|
|
44
45
|
MongoMixin.processid__client_map[pid] = pymongo.MongoClient(funboost_config_deafult.MONGO_CONNECT_URL, connect=False)
|
|
@@ -51,3 +52,12 @@ class MongoMixin:
|
|
|
51
52
|
MongoMixin.processid__db_map[pid] = self.mongo_client.get_database('task_status')
|
|
52
53
|
return MongoMixin.processid__db_map[pid]
|
|
53
54
|
|
|
55
|
+
def get_mongo_collection(self,database_name,colleciton_name):
|
|
56
|
+
pid = os.getpid()
|
|
57
|
+
if pid not in MongoMixin.processid__col_map:
|
|
58
|
+
MongoMixin.processid__col_map[pid] = self.mongo_client.get_database(database_name).get_collection(colleciton_name)
|
|
59
|
+
return MongoMixin.processid__col_map[pid]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: funboost
|
|
3
|
-
Version: 19.
|
|
3
|
+
Version: 19.2
|
|
4
4
|
Summary: pip install funboost,python全功能分布式函数调度框架,。支持python所有类型的并发模式和一切知名消息队列中间件,python函数加速器,框架包罗万象,一统编程思维,兼容50% python业务场景,适用范围广。只需要一行代码即可分布式执行python一切函数。旧名字是function_scheduling_distributed_framework
|
|
5
5
|
Home-page: https://github.com/ydf0509/funboost
|
|
6
6
|
Author: bfzs
|
|
@@ -23,7 +23,7 @@ funboost/concurrent_pool/backup/async_pool_executor0223.py,sha256=K13RheWQiX3Fc2
|
|
|
23
23
|
funboost/concurrent_pool/backup/async_pool_executor_back.py,sha256=-asM6fu3GLJKkkBZ1cbTSX9Iico74e6QEW6IWCpjk3M,9560
|
|
24
24
|
funboost/concurrent_pool/backup/async_pool_executor_janus.py,sha256=cZ0Vm0qeT3sKcWQ6B6M6EIP1Wyk9WDHjk1TWAB1YQpc,5724
|
|
25
25
|
funboost/consumers/__init__.py,sha256=ZXY_6Kut1VYNQiF5aWEgIWobsW1ht9YUP0TdRZRWFqI,126
|
|
26
|
-
funboost/consumers/base_consumer.py,sha256=
|
|
26
|
+
funboost/consumers/base_consumer.py,sha256=CzjbZZt6HkydI5OnB2wfJJcBTM6EnrTENRBQk4HwxxA,84457
|
|
27
27
|
funboost/consumers/confirm_mixin.py,sha256=C2TYSRJ2vnXAVetd7YNcQ-LQq-HZgQZSAXXzsJ6rmUY,5497
|
|
28
28
|
funboost/consumers/http_consumer.py,sha256=m9-o0nNeiG7UFr6iLhpfNuMd0bQNYI38i4cw0vC8MjM,2041
|
|
29
29
|
funboost/consumers/http_consumer000.py,sha256=NXOSiN1qpLAJfJkuF6SjFpWQ28YxMDULzWCBTNMwYe8,4463
|
|
@@ -62,7 +62,7 @@ funboost/factories/__init__.py,sha256=s7kKKjR1HU5eMjPD6r5b-SXTVMo1zBp2JjOAtkyt5Y
|
|
|
62
62
|
funboost/factories/consumer_factory.py,sha256=UY063zP7GQB4kYxG1WDbn8jINy3vNSiU9SJ0ZZFaagQ,3218
|
|
63
63
|
funboost/factories/publisher_factotry.py,sha256=FvpPIAH174huwb5gfrXpt_g44ZwViJi2RIfkmrHKNMY,4504
|
|
64
64
|
funboost/function_result_web/app.py,sha256=xUSDBwwDA5wQVWFdFBXj9Y1s7BOh2itUw5pCZl0URMw,4841
|
|
65
|
-
funboost/function_result_web/functions.py,sha256=
|
|
65
|
+
funboost/function_result_web/functions.py,sha256=OIPMxc4jv51qnhBxFGfTZnpMx5p4lQflPoTviDTbJUc,7345
|
|
66
66
|
funboost/function_result_web/__pycache__/app.cpython-37.pyc,sha256=p-jwU7xf31KOJhmhNXqj6J79PTxjMbiTU16gAotpSEw,4045
|
|
67
67
|
funboost/function_result_web/__pycache__/functions.cpython-37.pyc,sha256=KuU8DnYhFpYN0p9rdDXE9mqFuE7eKkcXHCNze3aAdOw,3921
|
|
68
68
|
funboost/function_result_web/static/assets/css/custom.css,sha256=3brvjy2aBOTIXcTUK4NV6dX5wFRqx6K2aLu_jQn63jM,7674
|
|
@@ -86,7 +86,7 @@ funboost/publishers/httpsqs_publisher.py,sha256=7cf5ijwrbp4smq6ofndrKisruAqG0Wzf
|
|
|
86
86
|
funboost/publishers/kafka_publisher.py,sha256=49JKL9PopDSIiQ3ZKBSSNPhByR-owxc2pbM4nT4Tc6g,2156
|
|
87
87
|
funboost/publishers/kombu_publisher.py,sha256=ChX3qVE7Kvdu9XVFCKezV2KAwUqY7EhpvMS8nFelsY8,4567
|
|
88
88
|
funboost/publishers/local_python_queue_publisher.py,sha256=veskMS5tjeneYU9HmrJLXZSK9_UT48NzHzcljjOoy3g,1365
|
|
89
|
-
funboost/publishers/mongomq_publisher.py,sha256=
|
|
89
|
+
funboost/publishers/mongomq_publisher.py,sha256=Aia8xIJc6GhFNftyYhTQq0KtLbPDR8IM3AnAm6bky4Y,1814
|
|
90
90
|
funboost/publishers/mqtt_publisher.py,sha256=NKVDE5R12QL99IXgRjJtF4phyW8QaXKxHkqW5p_kXr4,3050
|
|
91
91
|
funboost/publishers/msg_result_getter.py,sha256=R_tYQUgnZtTUWge--i1j_aYZLY3wysNTTFKCQ2JKQbE,6161
|
|
92
92
|
funboost/publishers/nats_publisher.py,sha256=hFfaQovij9dm8w-iRN0SgiHHoS_TlrTAjw42dPwCLSA,776
|
|
@@ -123,7 +123,7 @@ funboost/utils/custom_pysnooper.py,sha256=7yXLKEMY_JjPRRt0Y0N-wV2CFhILlYNh40Y6uR
|
|
|
123
123
|
funboost/utils/decorators.py,sha256=1JdiRucuQf_kApRO7gqxiD6K5eUuK_HjetURNRlodxQ,24272
|
|
124
124
|
funboost/utils/develop_log.py,sha256=f82JHBPBjdF_By5P_Ft4wMREeIHtF8MmqGFYa_pZbyA,251
|
|
125
125
|
funboost/utils/log_manager000.py,sha256=GT9rR9O-UDeaFwTCwt68xdVAmrw0vmAi1FofjRSXrJ4,73634
|
|
126
|
-
funboost/utils/mongo_util.py,sha256=
|
|
126
|
+
funboost/utils/mongo_util.py,sha256=BWZnkbyHU7-zFCQ5r0Ajib5kK1S-INUR3IbE5ejIxzo,2297
|
|
127
127
|
funboost/utils/monkey_color_log.py,sha256=jxxxVKebX0MmVjg75YRXUOBhPbksPBrHp2KLxCj6pT8,7357
|
|
128
128
|
funboost/utils/monkey_patches.py,sha256=Q0_jKxOfFrSgrIDSuSZFrgNh6w_LRGaKAITghrIpEwI,2882
|
|
129
129
|
funboost/utils/mqtt_util.py,sha256=BfCmyYwI-B8VL9499_IuYlJDCbv6ZhwyWThMf8dANOU,3199
|
|
@@ -157,8 +157,8 @@ funboost/utils/pysnooper_ydf/pycompat.py,sha256=ehsCfjsLdwoK0_o5fwYWDo3WeqCVfHW5
|
|
|
157
157
|
funboost/utils/pysnooper_ydf/tracer.py,sha256=2leNcEhT0qt2B_7Vn094dep9AG0qnRX94imQHm4Qp8k,19122
|
|
158
158
|
funboost/utils/pysnooper_ydf/utils.py,sha256=Y0nGXPqdiHBwO93TQAyYNbrzXtcK3_BQXrDVyjcTqVw,2748
|
|
159
159
|
funboost/utils/pysnooper_ydf/variables.py,sha256=N12-WKrg4GFt3X1aw9c-jwuVbn2wQTNZXscrYP9RM2k,3678
|
|
160
|
-
funboost-19.
|
|
161
|
-
funboost-19.
|
|
162
|
-
funboost-19.
|
|
163
|
-
funboost-19.
|
|
164
|
-
funboost-19.
|
|
160
|
+
funboost-19.2.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
161
|
+
funboost-19.2.dist-info/METADATA,sha256=_8V8rpfUTACU5cBPRhdxHkF_Nduoi8X3swyry2mQ1hA,25630
|
|
162
|
+
funboost-19.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
163
|
+
funboost-19.2.dist-info/top_level.txt,sha256=K8WuKnS6MRcEWxP1NvbmCeujJq6TEfbsB150YROlRw0,9
|
|
164
|
+
funboost-19.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|