funboost 48.7__py3-none-any.whl → 48.9__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/__main__.py +2 -0
- funboost/concurrent_pool/custom_threadpool_executor.py +1 -1
- funboost/constant.py +17 -2
- funboost/consumers/base_consumer.py +42 -28
- funboost/consumers/rabbitmq_amqpstorm_consumer.py +6 -1
- funboost/core/active_cousumer_info_getter.py +50 -10
- funboost/core/booster.py +2 -1
- funboost/core/cli/funboost_fire.py +10 -0
- funboost/core/current_task.py +17 -0
- funboost/core/func_params_model.py +21 -17
- funboost/core/loggers.py +1 -0
- funboost/core/msg_result_getter.py +1 -0
- funboost/funboost_config_deafult.py +1 -1
- funboost/function_result_web/__pycache__/app.cpython-37.pyc +0 -0
- funboost/function_result_web/__pycache__/app.cpython-39.pyc +0 -0
- funboost/function_result_web/__pycache__/functions.cpython-37.pyc +0 -0
- funboost/function_result_web/__pycache__/functions.cpython-39.pyc +0 -0
- funboost/function_result_web/app.py +42 -2
- funboost/function_result_web/app_debug_start.py +6 -0
- funboost/function_result_web/functions.py +66 -3
- funboost/function_result_web/static/js/form-memory.js +92 -0
- funboost/function_result_web/static/js_cdn/chart.js +20 -0
- funboost/function_result_web/static/js_cdn/tabulator-tables@5.5.0/dist/js/tabulator.min.js +1 -1
- funboost/function_result_web/templates/about.html +0 -9
- funboost/function_result_web/templates/conusme_speed.html +2 -2
- funboost/function_result_web/templates/fun_result_table.html +1 -1
- funboost/function_result_web/templates/index.html +64 -9
- funboost/function_result_web/templates/queue_op.html +419 -28
- funboost/function_result_web/templates/rpc_call.html +312 -0
- funboost/function_result_web/templates/running_consumer_by_ip.html +2 -2
- funboost/function_result_web/templates/running_consumer_by_queue_name.html +2 -2
- funboost/publishers/rabbitmq_amqpstorm_publisher.py +1 -1
- funboost/utils/ctrl_c_end.py +19 -1
- funboost/utils/dependency_packages_in_pythonpath/aioredis/readme.md +6 -0
- funboost/utils/dependency_packages_in_pythonpath/readme.md +6 -0
- {funboost-48.7.dist-info → funboost-48.9.dist-info}/METADATA +173 -81
- {funboost-48.7.dist-info → funboost-48.9.dist-info}/RECORD +42 -39
- {funboost-48.7.dist-info → funboost-48.9.dist-info}/WHEEL +1 -1
- 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 +0 -153
- {funboost-48.7.dist-info → funboost-48.9.dist-info}/LICENSE +0 -0
- {funboost-48.7.dist-info → funboost-48.9.dist-info}/entry_points.txt +0 -0
- {funboost-48.7.dist-info → funboost-48.9.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
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="{{ url_for('static',filename='css_cdn/twitter-bootstrap/3.3.7/css/bootstrap.min.css') }}" rel="stylesheet">
|
|
10
|
+
<link href="{{ url_for('static',filename='css_cdn/font-awesome/4.7.0/css/font-awesome.min.css') }}" rel="stylesheet">
|
|
11
|
+
<link rel="stylesheet"
|
|
12
|
+
href="{{ url_for('static',filename='css_cdn/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="{{ url_for('static',filename='css_cdn/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="{{ url_for('static',filename='js_cdn/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="{{ url_for('static',filename='css_cdn/tabulator-tables@5.5.0/tabulator.min.css') }}" rel="stylesheet">
|
|
41
|
+
<link href="{{ url_for('static',filename='css_cdn/tabulator-tables@5.5.0/tabulator_bootstrap3.min.css') }}" rel="stylesheet">
|
|
42
|
+
<script type="text/javascript" src="{{ url_for('static',filename='js_cdn/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
|
+
<!-- 添加发布消息和RPC结果区域 -->
|
|
53
|
+
<div class="row" style="margin-top: 20px;">
|
|
54
|
+
<div class="col-md-6">
|
|
55
|
+
<div style="background-color: #f9f9f9; border-radius: 8px; padding: 20px; border-left: 5px solid #3498db; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
|
|
56
|
+
<h1 style="margin-bottom: 20px;color: red;">发送rpc请求:</h1>
|
|
57
|
+
<div class="form-group">
|
|
58
|
+
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
|
59
|
+
|
|
60
|
+
<label for="col_name_search" style="margin-right: 5px; white-space: nowrap;">队列名字:</label>
|
|
61
|
+
<select class="form-control" id="col_name_search" style="width: 500px;">
|
|
62
|
+
<option value="">请选择队列名字...</option>
|
|
63
|
+
</select>
|
|
64
|
+
</div>
|
|
65
|
+
<textarea class="form-control" id="message_content" rows="7" placeholder="请输入消息体JSON格式,如:{"x":1,"y":2}"></textarea>
|
|
66
|
+
</div>
|
|
67
|
+
<div class="form-inline" style="margin-bottom: 15px;">
|
|
68
|
+
<div class="checkbox" style="margin-right: 20px;">
|
|
69
|
+
<label>
|
|
70
|
+
<input type="checkbox" id="need_result" checked> 需要返回结果
|
|
71
|
+
</label>
|
|
72
|
+
</div>
|
|
73
|
+
<div class="form-group" style="margin-right: 20px;">
|
|
74
|
+
<label for="timeout" style="margin-right: 5px;">超时时间(秒):</label>
|
|
75
|
+
<input type="number" class="form-control" id="timeout" value="60" style="width: 80px;">
|
|
76
|
+
</div>
|
|
77
|
+
<button type="button" class="btn btn-primary" id="send_btn">发送RPC请求</button>
|
|
78
|
+
</div>
|
|
79
|
+
<div class="alert alert-info" id="status_display" style="margin-top: 10px;">
|
|
80
|
+
准备发送RPC请求,请选择队列名称并输入消息内容
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<hr style="border-top: 2px dashed #3498db; margin: 40px 0;">
|
|
85
|
+
|
|
86
|
+
<div style="background-color: #f9f9f9; border-radius: 8px; padding: 20px; border-left: 5px solid #e74c3c; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
|
|
87
|
+
<h1 style="margin-bottom: 20px;color: red;">获取task_id结果:</h1>
|
|
88
|
+
<div class="form-group">
|
|
89
|
+
<div style="display: flex; align-items: center;">
|
|
90
|
+
<label for="task_id" style="margin-right: 5px; white-space: nowrap;">task_id:</label>
|
|
91
|
+
<input type="text" class="form-control" id="task_id" style="width: 500px; margin-right: 15px;">
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<div style="display: flex; align-items: center; margin-bottom: 15px;">
|
|
95
|
+
<div style="margin-right: 20px; display: flex; align-items: center;">
|
|
96
|
+
<label for="task_timeout" style="margin-right: 5px; white-space: nowrap;">超时时间(秒):</label>
|
|
97
|
+
<input type="number" class="form-control" id="task_timeout" value="30" style="width: 80px;">
|
|
98
|
+
</div>
|
|
99
|
+
<button type="button" class="btn btn-primary" id="get_result_btn">获取结果</button>
|
|
100
|
+
</div>
|
|
101
|
+
<div class="alert alert-info" id="task_status_display" style="margin-top: 10px;">
|
|
102
|
+
准备获取结果,请输入task_id
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
<div class="col-md-6">
|
|
111
|
+
<div class="form-group">
|
|
112
|
+
<label for="rpc_result">RPC结果:</label>
|
|
113
|
+
<textarea class="form-control" id="rpc_result" rows="39" readonly style="background-color: #1e1e1e; color: #ffffff; font-family: Consolas, Monaco, 'Courier New', monospace; border: 1px solid #333;"></textarea>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
<div id="result-table" style="margin-top: 20px;"></div>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
<script>
|
|
130
|
+
|
|
131
|
+
// 在现有的变量声明后添加
|
|
132
|
+
var allQueues = []; // 存储所有队列数据
|
|
133
|
+
var currentColName;
|
|
134
|
+
|
|
135
|
+
// 页面加载完成后立即获取所有队列
|
|
136
|
+
$(document).ready(function () {
|
|
137
|
+
$.ajax({
|
|
138
|
+
url: "{{ url_for('get_msg_num')}}",
|
|
139
|
+
data: {},
|
|
140
|
+
async: true,
|
|
141
|
+
success: function (result) {
|
|
142
|
+
var html = '<option value="">请选择队列名字...</option>';
|
|
143
|
+
for (var queueName in result) {
|
|
144
|
+
var msgCount = result[queueName];
|
|
145
|
+
html += '<option value="' + queueName + '">' +
|
|
146
|
+
queueName + ' (msg_count:' + msgCount + ')</option>';
|
|
147
|
+
}
|
|
148
|
+
$("#col_name_search").html(html);
|
|
149
|
+
|
|
150
|
+
// 初始化选择框的搜索功能
|
|
151
|
+
$("#col_name_search").select2({
|
|
152
|
+
placeholder: "请输入队列名称搜索...",
|
|
153
|
+
allowClear: true,
|
|
154
|
+
width: '500px',
|
|
155
|
+
minimumResultsForSearch: 0
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// 监听选择变化
|
|
159
|
+
$("#col_name_search").on('change', function () {
|
|
160
|
+
var selectedQueue = $(this).val();
|
|
161
|
+
console.log("Selected queue:", selectedQueue);
|
|
162
|
+
currentColName = selectedQueue;
|
|
163
|
+
// if(selectedQueue) {
|
|
164
|
+
// queryResult(selectedQueue, 0, true);
|
|
165
|
+
// }
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// 添加发送RPC请求的功能
|
|
172
|
+
$(document).ready(function() {
|
|
173
|
+
// 已有的队列加载代码...
|
|
174
|
+
|
|
175
|
+
// 发送RPC请求按钮点击事件
|
|
176
|
+
$("#send_btn").click(function() {
|
|
177
|
+
var queueName = $("#col_name_search").val();
|
|
178
|
+
var messageContent = $("#message_content").val();
|
|
179
|
+
|
|
180
|
+
if (!queueName) {
|
|
181
|
+
alert("请先选择队列名称");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (!messageContent) {
|
|
186
|
+
alert("请输入消息内容");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
// 尝试解析JSON,确保内容有效
|
|
192
|
+
JSON.parse(messageContent);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
alert("消息内容必须是有效的JSON格式");
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// 更新状态显示
|
|
199
|
+
$("#status_display").removeClass("alert-info alert-success alert-danger").addClass("alert-warning");
|
|
200
|
+
$("#status_display").text("正在发送RPC请求,请稍候...");
|
|
201
|
+
|
|
202
|
+
// 清空结果框
|
|
203
|
+
$("#rpc_result").val("");
|
|
204
|
+
$("#rpc_result").css({"background-color": "#1e1e1e", "color": "#ffffff"});
|
|
205
|
+
|
|
206
|
+
// 发送RPC请求
|
|
207
|
+
$.ajax({
|
|
208
|
+
url: "{{ url_for('rpc_call') }}",
|
|
209
|
+
type: "POST",
|
|
210
|
+
contentType: "application/json",
|
|
211
|
+
data: JSON.stringify({
|
|
212
|
+
queue_name: queueName,
|
|
213
|
+
msg_body: JSON.parse(messageContent),
|
|
214
|
+
need_result: $("#need_result").is(":checked"),
|
|
215
|
+
timeout: parseInt($("#timeout").val())
|
|
216
|
+
}),
|
|
217
|
+
success: function(result) {
|
|
218
|
+
|
|
219
|
+
console.log(result)
|
|
220
|
+
|
|
221
|
+
$("#rpc_result").val(JSON.stringify(result, null, 2));
|
|
222
|
+
|
|
223
|
+
// 更新状态显示
|
|
224
|
+
if (result.succ) {
|
|
225
|
+
$("#status_display").removeClass("alert-warning alert-danger").addClass("alert-success");
|
|
226
|
+
$("#status_display").text("RPC请求成功: " + result.msg);
|
|
227
|
+
$("#rpc_result").css({"background-color": "#5cb85c", "color": "#ffffff"});
|
|
228
|
+
} else {
|
|
229
|
+
$("#status_display").removeClass("alert-warning alert-success").addClass("alert-danger");
|
|
230
|
+
$("#status_display").text("RPC请求失败: " + result.msg);
|
|
231
|
+
$("#rpc_result").css({"background-color": "#d9534f", "color": "#ffffff"});
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
error: function(xhr, status, error) {
|
|
235
|
+
$("#rpc_result").val("请求失败: " + error);
|
|
236
|
+
$("#rpc_result").css({"background-color": "#d9534f", "color": "#ffffff"});
|
|
237
|
+
|
|
238
|
+
// 更新状态显示
|
|
239
|
+
$("#status_display").removeClass("alert-warning alert-success").addClass("alert-danger");
|
|
240
|
+
$("#status_display").text("RPC请求发送失败: " + error);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// 添加获取结果功能
|
|
247
|
+
$(document).ready(function() {
|
|
248
|
+
// 获取结果按钮点击事件
|
|
249
|
+
$("#get_result_btn").click(function() {
|
|
250
|
+
var taskId = $("#task_id").val();
|
|
251
|
+
|
|
252
|
+
if (!taskId) {
|
|
253
|
+
alert("请先输入task_id");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// 更新状态显示
|
|
258
|
+
$("#task_status_display").removeClass("alert-info alert-success alert-danger").addClass("alert-warning");
|
|
259
|
+
$("#task_status_display").text("正在获取结果,请稍候...");
|
|
260
|
+
|
|
261
|
+
// 清空结果框
|
|
262
|
+
$("#rpc_result").val("");
|
|
263
|
+
$("#rpc_result").css({"background-color": "#1e1e1e", "color": "#ffffff"});
|
|
264
|
+
|
|
265
|
+
// 获取结果
|
|
266
|
+
$.ajax({
|
|
267
|
+
url: "{{ url_for('get_result_by_task_id') }}",
|
|
268
|
+
type: "GET",
|
|
269
|
+
data: {
|
|
270
|
+
task_id: taskId,
|
|
271
|
+
timeout: parseInt($("#task_timeout").val())
|
|
272
|
+
},
|
|
273
|
+
success: function(result) {
|
|
274
|
+
console.log(result);
|
|
275
|
+
$("#rpc_result").val(JSON.stringify(result, null, 2));
|
|
276
|
+
|
|
277
|
+
// 更新状态显示
|
|
278
|
+
if (result.succ) {
|
|
279
|
+
$("#task_status_display").removeClass("alert-warning alert-danger").addClass("alert-success");
|
|
280
|
+
$("#task_status_display").text("获取结果成功");
|
|
281
|
+
$("#rpc_result").css({"background-color": "#5cb85c", "color": "#ffffff"});
|
|
282
|
+
} else {
|
|
283
|
+
$("#task_status_display").removeClass("alert-warning alert-success").addClass("alert-danger");
|
|
284
|
+
$("#task_status_display").text("获取结果失败: " + result.msg);
|
|
285
|
+
$("#rpc_result").css({"background-color": "#d9534f", "color": "#ffffff"});
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
error: function(xhr, status, error) {
|
|
289
|
+
$("#rpc_result").val("请求失败: " + error);
|
|
290
|
+
$("#rpc_result").css({"background-color": "#d9534f", "color": "#ffffff"});
|
|
291
|
+
|
|
292
|
+
// 更新状态显示
|
|
293
|
+
$("#task_status_display").removeClass("alert-warning alert-success").addClass("alert-danger");
|
|
294
|
+
$("#task_status_display").text("获取结果失败: " + error);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
</script>
|
|
310
|
+
</body>
|
|
311
|
+
|
|
312
|
+
</html>
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
var html = '<option value="">请选择ip...</option>';
|
|
88
88
|
for (var item of result) {
|
|
89
89
|
html += '<option value="' + item.collection_name + '">' +
|
|
90
|
-
item.collection_name + '
|
|
90
|
+
item.collection_name + ' (consumer_count:' + item.count + ')</option>';
|
|
91
91
|
}
|
|
92
92
|
$("#col_name_search").html(html);
|
|
93
93
|
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
$("#col_name_search").select2({
|
|
96
96
|
placeholder: "请输入ip名称搜索...",
|
|
97
97
|
allowClear: true,
|
|
98
|
-
width: '
|
|
98
|
+
width: '500px'
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
// 监听选择变化
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
var html = '<option value="">请选择队列名字...</option>';
|
|
88
88
|
for (var item of result) {
|
|
89
89
|
html += '<option value="' + item.collection_name + '">' +
|
|
90
|
-
item.collection_name + '
|
|
90
|
+
item.collection_name + ' (consumer_count:' + item.count + ')</option>';
|
|
91
91
|
}
|
|
92
92
|
$("#col_name_search").html(html);
|
|
93
93
|
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
$("#col_name_search").select2({
|
|
96
96
|
placeholder: "请输入队列名称搜索...",
|
|
97
97
|
allowClear: true,
|
|
98
|
-
width: '
|
|
98
|
+
width: '500px'
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
// 监听选择变化
|
|
@@ -20,7 +20,7 @@ class RabbitmqPublisherUsingAmqpStorm(AbstractPublisher):
|
|
|
20
20
|
|
|
21
21
|
def custom_init(self):
|
|
22
22
|
arguments = {} # {'x-queue-type':'classic'} classic stream lazy quorum
|
|
23
|
-
if self.publisher_params.broker_exclusive_config
|
|
23
|
+
if self.publisher_params.broker_exclusive_config.get('x-max-priority'):
|
|
24
24
|
arguments['x-max-priority'] = self.publisher_params.broker_exclusive_config['x-max-priority']
|
|
25
25
|
self.queue_declare_params = dict(queue=self._queue_name, durable=self.DURABLE, arguments=arguments,auto_delete=False)
|
|
26
26
|
|
funboost/utils/ctrl_c_end.py
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
3
|
import time
|
|
4
|
+
import signal
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def signal_handler(signum, frame):
|
|
8
|
+
print(f'收到信号 {signum},程序准备退出', flush=True)
|
|
9
|
+
sys.exit(4)
|
|
10
|
+
os._exit(44)
|
|
4
11
|
|
|
5
12
|
|
|
6
13
|
def ctrl_c_recv():
|
|
14
|
+
"""
|
|
15
|
+
主要目的就是阻止主线程退出而已。 因为funboost为了方便用户连续启动多个consume都是子线程运行循环调度的。
|
|
16
|
+
apscheduler background 类型必须有主线程在运行,否则会很快结束。所以需要阻止主线程退出。
|
|
17
|
+
在代码最最末尾加上 ctrl_c_recv() 就可以阻止主线程退出。
|
|
18
|
+
|
|
19
|
+
你也可以直接在你的启动脚本的最末尾加上:
|
|
20
|
+
while 1:
|
|
21
|
+
time.sleep(100)
|
|
22
|
+
来达到阻止主线程退出的目的。
|
|
23
|
+
"""
|
|
24
|
+
# signal.signal(signal.SIGTERM, signal_handler)
|
|
25
|
+
|
|
7
26
|
for i in range(3):
|
|
8
27
|
while 1:
|
|
9
28
|
try:
|
|
@@ -14,6 +33,5 @@ def ctrl_c_recv():
|
|
|
14
33
|
# time.sleep(2)
|
|
15
34
|
break
|
|
16
35
|
# sys.exit(4)
|
|
17
|
-
|
|
18
36
|
os._exit(44)
|
|
19
37
|
# exit(444)
|