funboost 43.4__py3-none-any.whl → 43.6__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/booster.py +1 -1
- funboost/core/fabric_deploy_helper.py +22 -15
- funboost/core/lazy_impoter.py +12 -3
- funboost/utils/decorators.py +3 -2
- {funboost-43.4.dist-info → funboost-43.6.dist-info}/METADATA +2 -1
- {funboost-43.4.dist-info → funboost-43.6.dist-info}/RECORD +11 -11
- {funboost-43.4.dist-info → funboost-43.6.dist-info}/LICENSE +0 -0
- {funboost-43.4.dist-info → funboost-43.6.dist-info}/WHEEL +0 -0
- {funboost-43.4.dist-info → funboost-43.6.dist-info}/entry_points.txt +0 -0
- {funboost-43.4.dist-info → funboost-43.6.dist-info}/top_level.txt +0 -0
funboost/__init__.py
CHANGED
funboost/core/booster.py
CHANGED
|
@@ -66,7 +66,7 @@ class Booster:
|
|
|
66
66
|
flogger.warning(f'''你的 {queue_name} 队列, funboost 40.0版本以后: {BoostDecoParamsIsOldVersion.new_version_change_hint}''')
|
|
67
67
|
boost_params_merge = boost_params.copy()
|
|
68
68
|
boost_params_merge.update_from_dict(kwargs)
|
|
69
|
-
self.boost_params = boost_params_merge
|
|
69
|
+
self.boost_params:BoosterParams = boost_params_merge
|
|
70
70
|
self.queue_name = boost_params_merge.queue_name
|
|
71
71
|
|
|
72
72
|
def __str__(self):
|
|
@@ -4,25 +4,25 @@ import sys
|
|
|
4
4
|
import threading
|
|
5
5
|
import time
|
|
6
6
|
import os
|
|
7
|
-
|
|
7
|
+
import typing
|
|
8
|
+
from pathlib import Path
|
|
8
9
|
from fabric2 import Connection
|
|
9
|
-
|
|
10
|
+
from nb_libs.path_helper import PathHelper
|
|
10
11
|
# from funboost.core.booster import Booster
|
|
11
12
|
from funboost.utils.paramiko_util import ParamikoFolderUploader
|
|
12
13
|
|
|
13
14
|
# import nb_log
|
|
14
15
|
from funboost.core.loggers import get_funboost_file_logger
|
|
15
16
|
from funboost.core.booster import Booster
|
|
17
|
+
|
|
16
18
|
logger = get_funboost_file_logger(__name__)
|
|
17
19
|
|
|
18
|
-
def _remove_drive_letter(path):
|
|
19
|
-
if os.name == 'nt' and len(path) >= 3 and path[1] == ':':
|
|
20
|
-
return path[2:]
|
|
21
|
-
else:
|
|
22
|
-
return path
|
|
23
20
|
|
|
24
21
|
# noinspection PyDefaultArgument
|
|
25
|
-
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def fabric_deploy(booster: Booster, host, port, user, password,
|
|
26
26
|
path_pattern_exluded_tuple=('/.git/', '/.idea/', '/dist/', '/build/'),
|
|
27
27
|
file_suffix_tuple_exluded=('.pyc', '.log', '.gz'),
|
|
28
28
|
only_upload_within_the_last_modify_time=3650 * 24 * 60 * 60,
|
|
@@ -71,13 +71,22 @@ def fabric_deploy(booster:Booster, host, port, user, password,
|
|
|
71
71
|
task_fun.fabric_deploy('192.168.6.133', 22, 'ydf', '123456', process_num=2) 只需要这样就可以自动部署在远程机器运行,无需任何额外操作。
|
|
72
72
|
"""
|
|
73
73
|
# print(locals())
|
|
74
|
-
python_proj_dir =
|
|
74
|
+
python_proj_dir = sys.path[1].replace('\\', '/') + '/'
|
|
75
75
|
python_proj_dir_short = python_proj_dir.split('/')[-2]
|
|
76
76
|
# 获取被调用函数所在模块文件名
|
|
77
|
-
file_name =
|
|
78
|
-
|
|
79
|
-
relative_file_name = re.sub(f'^{python_proj_dir}', '', file_name)
|
|
77
|
+
file_name = sys._getframe(2).f_code.co_filename.replace('\\', '/') # noqa
|
|
78
|
+
relative_file_name = Path(file_name).relative_to(Path(python_proj_dir)).as_posix()
|
|
80
79
|
relative_module = relative_file_name.replace('/', '.')[:-3] # -3是去掉.py
|
|
80
|
+
func_name = booster.consuming_function.__name__
|
|
81
|
+
module_obj = PathHelper(sys._getframe(2).f_code.co_filename).import_as_module() # noqa
|
|
82
|
+
|
|
83
|
+
"""以下这种是为了兼容 函数没有@boost.而是使用 boosterxx = BoostersManager.build_booster() 来创建的booster. 下面的 python_exec_str 中需要用到 func_name """
|
|
84
|
+
for var_name,var_value in module_obj.__dict__.items():
|
|
85
|
+
if isinstance(var_value,Booster) and var_value.queue_name == booster.queue_name:
|
|
86
|
+
func_name = var_name
|
|
87
|
+
|
|
88
|
+
# print(file_name, python_proj_dir, relative_module, func_name)
|
|
89
|
+
# print(relative_module)
|
|
81
90
|
if user == 'root': # 文件夹会被自动创建,无需用户创建。
|
|
82
91
|
remote_dir = f'/codes/{python_proj_dir_short}'
|
|
83
92
|
else:
|
|
@@ -93,15 +102,13 @@ def fabric_deploy(booster:Booster, host, port, user, password,
|
|
|
93
102
|
logger.info(f'上传 本地文件夹代码 {python_proj_dir} 上传到远程 {host} 的 {remote_dir} 文件夹耗时 {round(time.perf_counter() - t_start, 3)} 秒')
|
|
94
103
|
# conn.run(f'''export PYTHONPATH={remote_dir}:$PYTHONPATH''')
|
|
95
104
|
|
|
96
|
-
func_name = booster.consuming_function.__name__
|
|
97
105
|
queue_name = booster.consumer.queue_name
|
|
98
|
-
|
|
99
106
|
process_mark = f'funboost_fabric_mark__{queue_name}__{func_name}'
|
|
100
107
|
conn = Connection(host, port=port, user=user, connect_kwargs={"password": password}, )
|
|
101
108
|
kill_shell = f'''ps -aux|grep {process_mark}|grep -v grep|awk '{{print $2}}' |xargs kill -9'''
|
|
102
109
|
logger.warning(f'{kill_shell} 命令杀死 {process_mark} 标识的进程')
|
|
103
110
|
# uploader.ssh.exec_command(kill_shell)
|
|
104
|
-
conn.run(kill_shell, encoding='utf-8',warn=True) # 不想提示,免得烦扰用户以为有什么异常了。所以用上面的paramiko包的ssh.exec_command
|
|
111
|
+
conn.run(kill_shell, encoding='utf-8', warn=True) # 不想提示,免得烦扰用户以为有什么异常了。所以用上面的paramiko包的ssh.exec_command
|
|
105
112
|
|
|
106
113
|
python_exec_str = f'''export is_funboost_remote_run=1;export PYTHONPATH={remote_dir}:$PYTHONPATH ;{python_interpreter} -c "from {relative_module} import {func_name};{func_name}.multi_process_consume({process_num})" -funboostmark {process_mark} '''
|
|
107
114
|
shell_str = f'''cd {remote_dir}; {python_exec_str}'''
|
funboost/core/lazy_impoter.py
CHANGED
|
@@ -26,8 +26,11 @@ class LazyImpoter(SingletonBaseNew):
|
|
|
26
26
|
lazy_impoter = LazyImpoter()
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
# noinspection SpellCheckingInspection
|
|
30
|
+
@singleton
|
|
31
|
+
class GeventImporter:
|
|
30
32
|
"""
|
|
33
|
+
避免提前导入
|
|
31
34
|
import gevent
|
|
32
35
|
from gevent import pool as gevent_pool
|
|
33
36
|
from gevent import monkey
|
|
@@ -38,6 +41,7 @@ class GeventImporter(SingletonBaseNew):
|
|
|
38
41
|
@cached_method_result
|
|
39
42
|
def gevent(self):
|
|
40
43
|
import gevent
|
|
44
|
+
print('导入gevent')
|
|
41
45
|
return gevent
|
|
42
46
|
|
|
43
47
|
@property
|
|
@@ -50,6 +54,7 @@ class GeventImporter(SingletonBaseNew):
|
|
|
50
54
|
@cached_method_result
|
|
51
55
|
def monkey(self):
|
|
52
56
|
from gevent import monkey
|
|
57
|
+
print('导入gevent')
|
|
53
58
|
return monkey
|
|
54
59
|
|
|
55
60
|
@property
|
|
@@ -59,13 +64,16 @@ class GeventImporter(SingletonBaseNew):
|
|
|
59
64
|
return JoinableQueue
|
|
60
65
|
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
@singleton
|
|
68
|
+
class EventletImporter:
|
|
63
69
|
"""
|
|
70
|
+
避免提前导入
|
|
64
71
|
from eventlet import greenpool, monkey_patch, patcher, Timeout
|
|
65
72
|
"""
|
|
66
73
|
|
|
67
|
-
def
|
|
74
|
+
def __init__(self):
|
|
68
75
|
from eventlet import greenpool, monkey_patch, patcher, Timeout
|
|
76
|
+
print('导入eventlet')
|
|
69
77
|
self.greenpool = greenpool
|
|
70
78
|
self.monkey_patch = monkey_patch
|
|
71
79
|
self.patcher = patcher
|
|
@@ -76,3 +84,4 @@ if __name__ == '__main__':
|
|
|
76
84
|
for i in range(10000):
|
|
77
85
|
# lazy_impoter.BoostersManager
|
|
78
86
|
EventletImporter().greenpool
|
|
87
|
+
GeventImporter().JoinableQueue
|
funboost/utils/decorators.py
CHANGED
|
@@ -5,6 +5,7 @@ import abc
|
|
|
5
5
|
import logging
|
|
6
6
|
import random
|
|
7
7
|
import uuid
|
|
8
|
+
from typing import TypeVar
|
|
8
9
|
|
|
9
10
|
from flask import request as flask_request
|
|
10
11
|
# noinspection PyUnresolvedReferences
|
|
@@ -148,8 +149,8 @@ def synchronized(func):
|
|
|
148
149
|
|
|
149
150
|
return lock_func
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
def singleton(cls):
|
|
152
|
+
ClSX = TypeVar('CLSX')
|
|
153
|
+
def singleton(cls:ClSX) -> ClSX:
|
|
153
154
|
"""
|
|
154
155
|
单例模式装饰器,新加入线程锁,更牢固的单例模式,主要解决多线程如100线程同时实例化情况下可能会出现三例四例的情况,实测。
|
|
155
156
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: funboost
|
|
3
|
-
Version: 43.
|
|
3
|
+
Version: 43.6
|
|
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
|
|
@@ -27,6 +27,7 @@ Classifier: Topic :: Software Development :: Libraries
|
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
License-File: LICENSE
|
|
29
29
|
Requires-Dist: nb-log >=12.6
|
|
30
|
+
Requires-Dist: nb-libs >=0.9
|
|
30
31
|
Requires-Dist: pymongo ==4.3.3
|
|
31
32
|
Requires-Dist: AMQPStorm ==2.10.6
|
|
32
33
|
Requires-Dist: rabbitpy ==2.0.1
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
funboost/__init__.py,sha256=
|
|
1
|
+
funboost/__init__.py,sha256=d69oDPS-2ViwXUkHN7P-OC1DiWpXIz8fOx1K_V4qC8I,3832
|
|
2
2
|
funboost/__init__old.py,sha256=07A1MLsxLtuRQQOIfDyphddOwNBrGe34enoHWAnjV14,20379
|
|
3
3
|
funboost/__main__.py,sha256=-6Nogi666Y0LN8fVm3JmHGTOk8xEGWvotW_GDbSaZME,1065
|
|
4
4
|
funboost/constant.py,sha256=Yxt3WJt9D8ybcrgiojOy0qjnq5mffwTnTJplerGL0Oo,7188
|
|
@@ -81,16 +81,16 @@ funboost/contrib/redis_consume_latest_msg_broker.py,sha256=ESortBZ2qu_4PBCa3e3Fe
|
|
|
81
81
|
funboost/contrib/save_result_status_to_sqldb.py,sha256=AxvD7nHs4sjr9U0kwEZzyPKrsGdU_JzEgzzhh_V1_4w,4071
|
|
82
82
|
funboost/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
83
83
|
funboost/core/active_cousumer_info_getter.py,sha256=09fEc-BTEIRfDDfHmOvKnMjLjtOyp4edLsUlAXUR_Qs,4966
|
|
84
|
-
funboost/core/booster.py,sha256=
|
|
84
|
+
funboost/core/booster.py,sha256=UjkMjhEYchUB-FyaFhrVM1XeMTpDdONBKjZXa4ADlgQ,15845
|
|
85
85
|
funboost/core/current_task.py,sha256=rAIQVLqYqtlHVRkjl17yki-mqvuMb640ssGmto4RSdA,4864
|
|
86
86
|
funboost/core/exceptions.py,sha256=pLF7BkRJAfDiWp2_xGZqencmwdPiSQI1NENbImExknY,1311
|
|
87
|
-
funboost/core/fabric_deploy_helper.py,sha256=
|
|
87
|
+
funboost/core/fabric_deploy_helper.py,sha256=wJXR7pua3PVau63r3GFhPa_JlMgFnBsqdJFqYWrv7Sw,9598
|
|
88
88
|
funboost/core/func_params_model.py,sha256=ChxvSq_iVuYnGR_CdN9h9qNtvBq8sZ4BocdzCjgsQHc,18167
|
|
89
89
|
funboost/core/function_result_status_config.py,sha256=PyjqAQOiwsLt28sRtH-eYRjiI3edPFO4Nde0ILFRReE,1764
|
|
90
90
|
funboost/core/function_result_status_saver.py,sha256=UdokGSwU630t70AZnT9Ecj7GpYXORBDivlc9kadoI2E,9172
|
|
91
91
|
funboost/core/helper_funs.py,sha256=M9Ad9EzgHdP581X-vuFgCavJRoezLGXlXSFg7zyMWD0,1578
|
|
92
92
|
funboost/core/kill_remote_task.py,sha256=MZ5vWLGt6SxyN76h5Lf_id9tyVUzjR-qXNyJwXaGlZY,8129
|
|
93
|
-
funboost/core/lazy_impoter.py,sha256=
|
|
93
|
+
funboost/core/lazy_impoter.py,sha256=BnnCcTanjn-ghBXxQQE3BfhajVc60-2_cAe4XtmHDmI,2128
|
|
94
94
|
funboost/core/loggers.py,sha256=173aXdqE8nAe8t6OcVMNAFsCUClVrWQovdQhTAg9IyM,2407
|
|
95
95
|
funboost/core/msg_result_getter.py,sha256=oZDuLDR5XQNzzvgDTsA7wroICToPwrkU9-OAaXXUQSk,8031
|
|
96
96
|
funboost/core/muliti_process_enhance.py,sha256=64rkVa5Eel-0EY2B7lc1dQTRwX4ehARVvcxQVDa6jr0,3568
|
|
@@ -171,7 +171,7 @@ funboost/utils/block_exit.py,sha256=BnfxNYo3lnmhk686RAEoc4u3D4RU_iEMMMgu5L8gIuI,
|
|
|
171
171
|
funboost/utils/bulk_operation.py,sha256=u1cBL9qo3G-Pvr75coMg5p6EQxDkc8Iuf4C_PJI7BJQ,10013
|
|
172
172
|
funboost/utils/ctrl_c_end.py,sha256=FgT9An-qsUA5gW-V-UKWqOh5shC7C_uvTFn0fS7i8GI,439
|
|
173
173
|
funboost/utils/custom_pysnooper.py,sha256=7yXLKEMY_JjPRRt0Y0N-wV2CFhILlYNh40Y6uRBUaj8,5923
|
|
174
|
-
funboost/utils/decorators.py,sha256=
|
|
174
|
+
funboost/utils/decorators.py,sha256=AbZ3SkAJMGG6BrWGI-Zcz7GJqONjjGtxu8y1QUZGT8c,26127
|
|
175
175
|
funboost/utils/develop_log.py,sha256=Wsx0ongGjTit5xqgk1BztYlVEkC6d0-Y7GENXLedVqY,271
|
|
176
176
|
funboost/utils/expire_lock.py,sha256=AOkd1KlvZeIwQaz8ZoKxLpGxWgqQ4mfNHcFphh04o8Q,4732
|
|
177
177
|
funboost/utils/json_helper.py,sha256=HDdtLyZBGpWbUm7vmTypKXd8K-Hb-9BaxpdmRlKMYUI,1849
|
|
@@ -264,9 +264,9 @@ funboost/utils/pysnooper_ydf/utils.py,sha256=evSmGi_Oul7vSP47AJ0DLjFwoCYCfunJZ1m
|
|
|
264
264
|
funboost/utils/pysnooper_ydf/variables.py,sha256=QejRDESBA06KG9OH4sBT4J1M55eaU29EIHg8K_igaXo,3693
|
|
265
265
|
funboost/utils/times/__init__.py,sha256=Y4bQD3SIA_E7W2YvHq2Qdi0dGM4H2DxyFNdDOuFOq1w,2417
|
|
266
266
|
funboost/utils/times/version.py,sha256=11XfnZVVzOgIhXXdeN_mYfdXThfrsbQHpA0wCjz-hpg,17
|
|
267
|
-
funboost-43.
|
|
268
|
-
funboost-43.
|
|
269
|
-
funboost-43.
|
|
270
|
-
funboost-43.
|
|
271
|
-
funboost-43.
|
|
272
|
-
funboost-43.
|
|
267
|
+
funboost-43.6.dist-info/LICENSE,sha256=9EPP2ktG_lAPB8PjmWV-c9BiaJHc_FP6pPLcUrUwx0E,11562
|
|
268
|
+
funboost-43.6.dist-info/METADATA,sha256=3abU2sNFQyHTeXo3ijQ81LEyTAO1IahWpSIhX5FO--U,30440
|
|
269
|
+
funboost-43.6.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
270
|
+
funboost-43.6.dist-info/entry_points.txt,sha256=yMSSAGRzRAAhGyNNQHw24MooKlDZsaJ499_D6fPl58A,96
|
|
271
|
+
funboost-43.6.dist-info/top_level.txt,sha256=K8WuKnS6MRcEWxP1NvbmCeujJq6TEfbsB150YROlRw0,9
|
|
272
|
+
funboost-43.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|