funboost 48.0__py3-none-any.whl → 48.1__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.

Files changed (33) hide show
  1. funboost/__init__.py +1 -1
  2. funboost/constant.py +7 -0
  3. funboost/consumers/base_consumer.py +129 -68
  4. funboost/core/active_cousumer_info_getter.py +60 -0
  5. funboost/core/function_result_status_saver.py +1 -1
  6. funboost/function_result_web/__pycache__/functions.cpython-37.pyc +0 -0
  7. funboost/function_result_web/__pycache__/functions.cpython-39.pyc +0 -0
  8. funboost/function_result_web/app.py +104 -7
  9. funboost/function_result_web/functions.py +17 -4
  10. funboost/function_result_web/static/css/content_page_style.css +39 -0
  11. funboost/function_result_web/static/images/favicon.ico +0 -0
  12. funboost/function_result_web/static/js/bootstrap-datetimepicker.min.js +2 -0
  13. funboost/function_result_web/static/js/echarts.min.js +32478 -0
  14. funboost/function_result_web/static/js/moment-with-locales.min.js +1 -0
  15. funboost/function_result_web/static/js/select2.min.js +2 -0
  16. funboost/function_result_web/templates/about.html +67 -0
  17. funboost/function_result_web/templates/conusme_speed.html +217 -0
  18. funboost/function_result_web/templates/fun_result_table.html +433 -0
  19. funboost/function_result_web/templates/index.html +194 -423
  20. funboost/function_result_web/templates/index_backup.html +475 -0
  21. funboost/function_result_web/templates/index_/321/204/342/225/225/320/235/321/205/320/237/320/277/321/206/320/232/320/250/321/205/320/237/320/260.html +153 -0
  22. funboost/function_result_web/templates/queue_op.html +490 -0
  23. funboost/function_result_web/templates/running_consumer_by_ip.html +220 -0
  24. funboost/function_result_web/templates/running_consumer_by_queue_name.html +216 -0
  25. funboost/timing_job/timing_push.py +24 -24
  26. funboost/utils/dependency_packages_in_pythonpath/aioredis/readme.md +0 -6
  27. funboost/utils/dependency_packages_in_pythonpath/readme.md +0 -6
  28. {funboost-48.0.dist-info → funboost-48.1.dist-info}/METADATA +78 -76
  29. {funboost-48.0.dist-info → funboost-48.1.dist-info}/RECORD +33 -18
  30. {funboost-48.0.dist-info → funboost-48.1.dist-info}/WHEEL +1 -1
  31. {funboost-48.0.dist-info → funboost-48.1.dist-info}/LICENSE +0 -0
  32. {funboost-48.0.dist-info → funboost-48.1.dist-info}/entry_points.txt +0 -0
  33. {funboost-48.0.dist-info → funboost-48.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,220 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+ <title>pytho万能分布式函数调度框架</title>
9
+ <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
10
+ <link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
11
+ <link rel="stylesheet"
12
+ href="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css">
13
+ <link rel="stylesheet" href="{{ url_for('static',filename='assets/css/jquery.mCustomScrollbar.min.css') }}">
14
+ <link rel="stylesheet" href="{{ url_for('static',filename='assets/css/custom.css') }}">
15
+
16
+ <!-- 在其他 link 标签后添加 -->
17
+ <link href="https://cdn.bootcdn.net/ajax/libs/select2/4.0.13/css/select2.min.css" rel="stylesheet">
18
+ <link href="{{ url_for('static',filename='css/content_page_style.css') }}" rel="stylesheet">
19
+
20
+
21
+ <script src="{{ url_for('static',filename='js/jquery-1.11.0.min.js') }}" type="text/javascript"></script>
22
+ <!-- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.11.0/jquery.min.js"></script> -->
23
+ <!-- 在其他 script 标签后添加 -->
24
+ <!-- <script src="https://cdn.bootcdn.net/ajax/libs/select2/4.0.13/js/select2.min.js"></script> -->
25
+ <script src="{{ url_for('static',filename='/js/select2.min.js') }}"></script>
26
+ <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
27
+
28
+
29
+ <script src="{{ url_for('static',filename='js/moment-with-locales.min.js') }}"></script>
30
+ <script src="{{ url_for('static',filename='js/bootstrap-datetimepicker.min.js') }}"></script>
31
+ <!-- <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script> -->
32
+ <!-- <script type="text/javascript" src="https://cdn.bootcss.com/echarts/3.3.0/echarts.js"></script> -->
33
+ <script type="text/javascript" src="{{ url_for('static',filename='js/echarts.min.js') }}"></script>
34
+
35
+ <script src="{{ url_for('static',filename='assets/js/jquery.mCustomScrollbar.concat.min.js') }}"></script>
36
+ <script src="{{ url_for('static',filename='assets/js/custom.js') }}"></script>
37
+
38
+
39
+ <!-- 添加 Tabulator 样式和脚本 -->
40
+ <link href="https://unpkg.com/tabulator-tables@5.5.0/dist/css/tabulator.min.css" rel="stylesheet">
41
+ <link href="https://unpkg.com/tabulator-tables@5.5.0/dist/css/tabulator_bootstrap3.min.css" rel="stylesheet">
42
+ <script type="text/javascript" src="https://unpkg.com/tabulator-tables@5.5.0/dist/js/tabulator.min.js"></script>
43
+
44
+ <style>
45
+
46
+
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+
52
+ <div class="container-fluid" style="margin-top: 5px;">
53
+ <div style="margin-top: 5px;">
54
+ <form class="form-inline" role="form" style="">
55
+ <div class="form-group ">
56
+ <label for="col_name_search">host:</label>
57
+ <select class="form-control" id="col_name_search">
58
+ <option value="">请选择ip...</option>
59
+ </select>
60
+ </div>
61
+ <button type="button" class="btn btn-default marginLeft20" onclick="query()">查询</button>
62
+ </form>
63
+ </div>
64
+
65
+ <div id="result-table" style="margin-top: 20px;"></div>
66
+
67
+ </div>
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <script>
75
+
76
+ // 在现有的变量声明后添加
77
+ var allQueues = []; // 存储所有队列数据
78
+ var currentColName;
79
+
80
+ // 页面加载完成后立即获取所有队列
81
+ $(document).ready(function () {
82
+ $.ajax({
83
+ url: "{{ url_for('hearbeat_info_partion_by_ip')}}",
84
+ data: { col_name_search: '' },
85
+ async: true,
86
+ success: function (result) {
87
+ allQueues = result;
88
+ var html = '<option value="">请选择ip...</option>';
89
+ for (var item of result) {
90
+ html += '<option value="' + item.collection_name + '">' +
91
+ item.collection_name + ' (' + item.count + ')</option>';
92
+ }
93
+ $("#col_name_search").html(html);
94
+
95
+ // 初始化选择框的搜索功能
96
+ $("#col_name_search").select2({
97
+ placeholder: "请输入ip名称搜索...",
98
+ allowClear: true,
99
+ width: '300px'
100
+ });
101
+
102
+ // 监听选择变化
103
+ $("#col_name_search").on('change', function () {
104
+ var selectedQueue = $(this).val();
105
+ console.log("Selected queue:", selectedQueue);
106
+ currentColName = selectedQueue;
107
+ // if(selectedQueue) {
108
+ // queryResult(selectedQueue, 0, true);
109
+ // }
110
+ });
111
+ }
112
+ });
113
+ });
114
+
115
+ $(document).ready(function (){
116
+ query()
117
+ });
118
+
119
+
120
+ function query() {
121
+ $.ajax({
122
+ url: "{{ url_for('hearbeat_info_by_ip')}}",
123
+ data: { ip: currentColName },
124
+ async: true,
125
+ success: function (result) {
126
+ console.info(result);
127
+
128
+ // 创建表格
129
+ var table = new Tabulator("#result-table", {
130
+ theme: "bootstrap3",
131
+ data: result,
132
+ // layout: "fitColumns",
133
+ layout: "fitDataTable", // 改为 fitDataTable
134
+ responsiveLayout: false, // 禁用响应式布局
135
+ columns: [
136
+ {title: "<br><br>队列名称", field: "queue_name","width":200},
137
+ {title: "<br><br>消费函数", field: "consuming_function"},
138
+ {title: "<br><br>主机名", field: "computer_name"},
139
+ {title: "<br><br>IP地址", field: "computer_ip"},
140
+ {title: "<br><br>进程ID", field: "process_id"},
141
+ {title: "<br><br>启动时间", field: "start_datetime_str","width":200},
142
+ {title: "<br><br>最近心跳时间", field: "hearbeat_datetime_str","width":200},
143
+
144
+ {title:"近10秒<br>运行完成<br>消息个数",field:"last_x_s_execute_count", formatter:"html","width":100},
145
+ {title:"近10秒<br>运行失败<br>消息个数",field:"last_x_s_execute_count_fail", formatter:"html","width":100},
146
+ {title:"累计<br>运行完成<br>消息个数",field:"total_consume_count_from_start", formatter:"html","width":100},
147
+ {title:"累计<br>运行失败<br>消息个数",field:"total_consume_count_from_start_fail", formatter:"html","width":100},
148
+
149
+ {title: "<br><br>代码文件", field: "code_filename"},
150
+ // {title: "<br><br>consumer_id", field: "consumer_id"},
151
+ {title: "<br><br>consumer_uuid", field: "consumer_uuid"},
152
+ ],
153
+ pagination: true,
154
+ paginationSize: 1000,
155
+ locale: true,
156
+ langs: {
157
+ "zh-cn": {
158
+ "pagination": {
159
+ "first": "首页",
160
+ "first_title": "首页",
161
+ "last": "末页",
162
+ "last_title": "末页",
163
+ "prev": "上一页",
164
+ "prev_title": "上一页",
165
+ "next": "下一页",
166
+ "next_title": "下一页",
167
+ }
168
+ }
169
+ }
170
+ });
171
+
172
+ <!-- $("#result-table").css("width", "150%");-->
173
+
174
+ /* result 例如 [
175
+ {
176
+ "code_filename": "d:/codes/funboost/test_frame/test_function_status_result_persist/test_persist.py",
177
+ "computer_ip": "10.0.133.57",
178
+ "computer_name": "LAPTOP-7V78BBO2",
179
+ "consumer_id": 1462882757512,
180
+ "consumer_uuid": "88f568f7-9723-48ef-9cac-0370b2333a49",
181
+ "consuming_function": "f2",
182
+ "hearbeat_datetime_str": "2025-02-25 17:28:36",
183
+ "hearbeat_timestamp": 1740475716.783474,
184
+ "process_id": 34788,
185
+ "queue_name": "queue_test_f02t",
186
+ "start_datetime_str": "2025-02-25 16:33:19",
187
+ "start_timestamp": 1740472399.4628778
188
+ },
189
+ {
190
+ "code_filename": "d:/codes/funboost/test_frame/test_function_status_result_persist/test_persist.py",
191
+ "computer_ip": "10.0.133.57",
192
+ "computer_name": "LAPTOP-7V78BBO2",
193
+ "consumer_id": 1462882671944,
194
+ "consumer_uuid": "c52a8596-d632-4bac-a797-80375288f381",
195
+ "consuming_function": "f",
196
+ "hearbeat_datetime_str": "2025-02-25 17:28:36",
197
+ "hearbeat_timestamp": 1740475716.783336,
198
+ "process_id": 34788,
199
+ "queue_name": "queue_test_f01t",
200
+ "start_datetime_str": "2025-02-25 16:33:19",
201
+ "start_timestamp": 1740472399.4503505
202
+ }
203
+ ]
204
+ */
205
+
206
+ }
207
+ });
208
+ }
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+ </script>
218
+ </body>
219
+
220
+ </html>
@@ -0,0 +1,216 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+ <title>pytho万能分布式函数调度框架</title>
9
+ <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
10
+ <link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
11
+ <link rel="stylesheet"
12
+ href="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css">
13
+ <link rel="stylesheet" href="{{ url_for('static',filename='assets/css/jquery.mCustomScrollbar.min.css') }}">
14
+ <link rel="stylesheet" href="{{ url_for('static',filename='assets/css/custom.css') }}">
15
+
16
+ <!-- 在其他 link 标签后添加 -->
17
+ <link href="https://cdn.bootcdn.net/ajax/libs/select2/4.0.13/css/select2.min.css" rel="stylesheet">
18
+ <link href="{{ url_for('static',filename='css/content_page_style.css') }}" rel="stylesheet">
19
+
20
+
21
+ <script src="{{ url_for('static',filename='js/jquery-1.11.0.min.js') }}" type="text/javascript"></script>
22
+ <!-- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.11.0/jquery.min.js"></script> -->
23
+ <!-- 在其他 script 标签后添加 -->
24
+ <!-- <script src="https://cdn.bootcdn.net/ajax/libs/select2/4.0.13/js/select2.min.js"></script> -->
25
+ <script src="{{ url_for('static',filename='/js/select2.min.js') }}"></script>
26
+ <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
27
+
28
+
29
+ <script src="{{ url_for('static',filename='js/moment-with-locales.min.js') }}"></script>
30
+ <script src="{{ url_for('static',filename='js/bootstrap-datetimepicker.min.js') }}"></script>
31
+ <!-- <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script> -->
32
+ <!-- <script type="text/javascript" src="https://cdn.bootcss.com/echarts/3.3.0/echarts.js"></script> -->
33
+ <script type="text/javascript" src="{{ url_for('static',filename='js/echarts.min.js') }}"></script>
34
+
35
+ <script src="{{ url_for('static',filename='assets/js/jquery.mCustomScrollbar.concat.min.js') }}"></script>
36
+ <script src="{{ url_for('static',filename='assets/js/custom.js') }}"></script>
37
+
38
+
39
+ <!-- 添加 Tabulator 样式和脚本 -->
40
+ <link href="https://unpkg.com/tabulator-tables@5.5.0/dist/css/tabulator.min.css" rel="stylesheet">
41
+ <link href="https://unpkg.com/tabulator-tables@5.5.0/dist/css/tabulator_bootstrap3.min.css" rel="stylesheet">
42
+ <script type="text/javascript" src="https://unpkg.com/tabulator-tables@5.5.0/dist/js/tabulator.min.js"></script>
43
+
44
+ <style>
45
+
46
+ </style>
47
+ </head>
48
+
49
+ <body>
50
+
51
+ <div class="container-fluid" style="margin-top: 5px;">
52
+ <div style="margin-top: 5px;">
53
+ <form class="form-inline" role="form" style="">
54
+ <div class="form-group ">
55
+ <label for="col_name_search">队列名字:</label>
56
+ <select class="form-control" id="col_name_search">
57
+ <option value="">请选择队列名字...</option>
58
+ </select>
59
+ </div>
60
+ <button type="button" class="btn btn-default marginLeft20" onclick="query()">查询</button>
61
+ </form>
62
+ </div>
63
+
64
+ <div id="result-table" style="margin-top: 20px;"></div>
65
+
66
+ </div>
67
+
68
+
69
+
70
+
71
+
72
+
73
+ <script>
74
+
75
+ // 在现有的变量声明后添加
76
+ var allQueues = []; // 存储所有队列数据
77
+ var currentColName;
78
+
79
+ // 页面加载完成后立即获取所有队列
80
+ $(document).ready(function () {
81
+ $.ajax({
82
+ url: "{{ url_for('hearbeat_info_partion_by_queue_name')}}",
83
+ data: { col_name_search: '' },
84
+ async: true,
85
+ success: function (result) {
86
+ allQueues = result;
87
+ var html = '<option value="">请选择队列名字...</option>';
88
+ for (var item of result) {
89
+ html += '<option value="' + item.collection_name + '">' +
90
+ item.collection_name + ' (' + item.count + ')</option>';
91
+ }
92
+ $("#col_name_search").html(html);
93
+
94
+ // 初始化选择框的搜索功能
95
+ $("#col_name_search").select2({
96
+ placeholder: "请输入队列名称搜索...",
97
+ allowClear: true,
98
+ width: '300px'
99
+ });
100
+
101
+ // 监听选择变化
102
+ $("#col_name_search").on('change', function () {
103
+ var selectedQueue = $(this).val();
104
+ console.log("Selected queue:", selectedQueue);
105
+ currentColName = selectedQueue;
106
+ // if(selectedQueue) {
107
+ // queryResult(selectedQueue, 0, true);
108
+ // }
109
+ });
110
+ }
111
+ });
112
+ });
113
+
114
+ $(document).ready(function (){
115
+ query()
116
+ });
117
+
118
+ function query() {
119
+ $.ajax({
120
+ url: "{{ url_for('hearbeat_info_by_queue_name')}}",
121
+ data: { queue_name: currentColName },
122
+ async: true,
123
+ success: function (result) {
124
+ console.info(result);
125
+
126
+ // 创建表格
127
+ var table = new Tabulator("#result-table", {
128
+ theme: "bootstrap3",
129
+ data: result,
130
+
131
+ // layout: "fitColumns",
132
+ layout: "fitDataTable", // 改为 fitDataTable
133
+ responsiveLayout: false, // 禁用响应式布局
134
+ columns: [
135
+ {title: "<br><br>队列名称", field: "queue_name","width":200},
136
+ {title: "<br><br>消费函数", field: "consuming_function"},
137
+ {title: "<br><br>主机名", field: "computer_name"},
138
+ {title: "<br><br>IP地址", field: "computer_ip"},
139
+ {title: "<br><br>进程ID", field: "process_id"},
140
+ {title: "<br><br>启动时间", field: "start_datetime_str","width":200},
141
+ {title: "<br><br>最近心跳时间", field: "hearbeat_datetime_str","width":200},
142
+
143
+ {title:"近10秒<br>运行完成<br>消息个数",field:"last_x_s_execute_count", formatter:"html","width":100},
144
+ {title:"近10秒<br>运行失败<br>消息个数",field:"last_x_s_execute_count_fail", formatter:"html","width":100},
145
+ {title:"累计<br>运行完成<br>消息个数",field:"total_consume_count_from_start", formatter:"html","width":100},
146
+ {title:"累计<br>运行失败<br>消息个数",field:"total_consume_count_from_start_fail", formatter:"html","width":100},
147
+ {title: "<br><br>代码文件", field: "code_filename"},
148
+ // {title: "<br><br>consumer_id", field: "consumer_id"},
149
+ {title: "<br><br>consumer_uuid", field: "consumer_uuid"},
150
+ ],
151
+ pagination: true,
152
+ paginationSize: 1000,
153
+ locale: true,
154
+ langs: {
155
+ "zh-cn": {
156
+ "pagination": {
157
+ "first": "首页",
158
+ "first_title": "首页",
159
+ "last": "末页",
160
+ "last_title": "末页",
161
+ "prev": "上一页",
162
+ "prev_title": "上一页",
163
+ "next": "下一页",
164
+ "next_title": "下一页",
165
+ }
166
+ }
167
+ }
168
+ });
169
+
170
+ /* result 例如 [
171
+ {
172
+ "code_filename": "d:/codes/funboost/test_frame/test_function_status_result_persist/test_persist.py",
173
+ "computer_ip": "10.0.133.57",
174
+ "computer_name": "LAPTOP-7V78BBO2",
175
+ "consumer_id": 1462882757512,
176
+ "consumer_uuid": "88f568f7-9723-48ef-9cac-0370b2333a49",
177
+ "consuming_function": "f2",
178
+ "hearbeat_datetime_str": "2025-02-25 17:28:36",
179
+ "hearbeat_timestamp": 1740475716.783474,
180
+ "process_id": 34788,
181
+ "queue_name": "queue_test_f02t",
182
+ "start_datetime_str": "2025-02-25 16:33:19",
183
+ "start_timestamp": 1740472399.4628778
184
+ },
185
+ {
186
+ "code_filename": "d:/codes/funboost/test_frame/test_function_status_result_persist/test_persist.py",
187
+ "computer_ip": "10.0.133.57",
188
+ "computer_name": "LAPTOP-7V78BBO2",
189
+ "consumer_id": 1462882671944,
190
+ "consumer_uuid": "c52a8596-d632-4bac-a797-80375288f381",
191
+ "consuming_function": "f",
192
+ "hearbeat_datetime_str": "2025-02-25 17:28:36",
193
+ "hearbeat_timestamp": 1740475716.783336,
194
+ "process_id": 34788,
195
+ "queue_name": "queue_test_f01t",
196
+ "start_datetime_str": "2025-02-25 16:33:19",
197
+ "start_timestamp": 1740472399.4503505
198
+ }
199
+ ]
200
+ */
201
+
202
+ }
203
+ });
204
+ }
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+ </script>
214
+ </body>
215
+
216
+ </html>
@@ -5,6 +5,7 @@ from apscheduler.jobstores.redis import RedisJobStore
5
5
  from funboost.timing_job.timing_job_base import funboost_aps_scheduler, undefined
6
6
  from funboost.timing_job.apscheduler_use_redis_store import FunboostBackgroundSchedulerProcessJobsWithinRedisLock
7
7
  from funboost.funboost_config_deafult import FunboostCommonConfig
8
+ from apscheduler.schedulers.base import BaseScheduler
8
9
 
9
10
 
10
11
  class ApsJobAdder:
@@ -55,7 +56,7 @@ class ApsJobAdder:
55
56
  return redis_aps
56
57
 
57
58
  @property
58
- def aps_obj(self):
59
+ def aps_obj(self) -> BaseScheduler:
59
60
  if self.job_store_kind == 'redis':
60
61
  return self.get_funboost_redis_apscheduler(self.booster.queue_name)
61
62
  elif self.job_store_kind == 'memory':
@@ -63,17 +64,17 @@ class ApsJobAdder:
63
64
  else:
64
65
  raise ValueError('Unsupported job_store_kind')
65
66
 
66
- def add_push_job(self, trigger=None, args=None, kwargs=None,
67
+ def add_push_job(self, trigger=None, args=None, kwargs=None,
67
68
  id=None, name=None,
68
69
  misfire_grace_time=undefined, coalesce=undefined, max_instances=undefined,
69
70
  next_run_time=undefined, jobstore='default', executor='default',
70
- replace_existing=False, **trigger_args,):
71
+ replace_existing=False, **trigger_args, ):
71
72
  """
72
73
  这里的入参都是和apscheduler的add_job的入参一样的,funboost作者没有创造新的入参。
73
74
  但是官方apscheduler的入参第一个入参是函数,
74
75
  funboost的ApsJobAdder对象.add_push_job入参去掉了函数,因为类的实例化时候会把函数传进来,不需要再麻烦用户一次了。
75
76
  """
76
-
77
+
77
78
  if not getattr(self.aps_obj, 'has_started_flag', False):
78
79
  self.aps_obj.has_started_flag = True
79
80
  self.aps_obj.start(paused=False)
@@ -83,54 +84,53 @@ class ApsJobAdder:
83
84
  replace_existing, **trigger_args, )
84
85
 
85
86
 
86
-
87
-
88
-
89
87
  if __name__ == '__main__':
90
88
  """
91
89
  2025年后定时任务现在推荐使用 ApsJobAdder 写法 ,用户不需要亲自选择使用 apscheduler对象来添加定时任务
92
90
  """
93
- from funboost import boost, BrokerEnum,ctrl_c_recv,BoosterParams,ApsJobAdder
94
-
91
+ from funboost import boost, BrokerEnum, ctrl_c_recv, BoosterParams, ApsJobAdder
92
+
95
93
 
96
94
  # 定义任务处理函数
97
95
  @BoosterParams(queue_name='sum_queue3', broker_kind=BrokerEnum.REDIS)
98
- def sum_two_numbers(x, y):
99
- result = x + y
100
- print(f'The sum of {x} and {y} is {result}')
101
-
96
+ def sum_two_numbers(x, y):
97
+ result = x + y
98
+ print(f'The sum of {x} and {y} is {result}')
99
+
102
100
  # 启动消费者
103
101
  sum_two_numbers.consume()
104
-
102
+
105
103
  # 发布任务
106
104
  sum_two_numbers.push(3, 5)
107
105
  sum_two_numbers.push(10, 20)
108
-
106
+
107
+
108
+
109
109
  # 使用ApsJobAdder添加定时任务, 里面的定时语法,和apscheduler是一样的,用户需要自己熟悉知名框架apscheduler的add_job定时入参
110
110
 
111
111
  # 方式1:指定日期执行一次
112
112
  ApsJobAdder(sum_two_numbers, job_store_kind='redis').add_push_job(
113
113
  trigger='date',
114
- run_date='2025-01-17 23:25:40',
114
+ run_date='2025-01-17 23:25:40',
115
115
  args=(7, 8)
116
116
  )
117
117
 
118
118
  # 方式2:固定间隔执行
119
119
  ApsJobAdder(sum_two_numbers, job_store_kind='memory').add_push_job(
120
- trigger='interval',
121
- seconds=5,
120
+ trigger='interval',
121
+ seconds=5,
122
122
  args=(4, 6)
123
123
  )
124
124
 
125
125
  # 方式3:使用cron表达式定时执行
126
126
  ApsJobAdder(sum_two_numbers, job_store_kind='redis').add_push_job(
127
127
  trigger='cron',
128
- day_of_week='*',
129
- hour=23,
130
- minute=49,
128
+ day_of_week='*',
129
+ hour=23,
130
+ minute=49,
131
131
  second=50,
132
- kwargs={"x":50,"y":60},
132
+ kwargs={"x": 50, "y": 60},
133
133
  replace_existing=True,
134
134
  id='cron_job1')
135
-
136
- ctrl_c_recv()
135
+
136
+ ctrl_c_recv()
@@ -1,9 +1,3 @@
1
- ---
2
- noteId: "647378a1e9bb11efa4500f7226f4d3b6"
3
- tags: []
4
-
5
- ---
6
-
7
1
 
8
2
  ## 1 asioredis包将不再更新 ,ptyhon 3.11 版本 import aioredis会出错。
9
3
 
@@ -1,9 +1,3 @@
1
- ---
2
- noteId: "647378a0e9bb11efa4500f7226f4d3b6"
3
- tags: []
4
-
5
- ---
6
-
7
1
  ## 这个文件夹被添加到 sys.path中去了。
8
2
 
9
3
  funboost __init__.py 第一行就把这个添加到 sys.path了,相当于 export PYTHONPATH 了。