mns-scheduler 1.3.3.0__py3-none-any.whl → 1.3.3.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 mns-scheduler might be problematic. Click here for more details.
- mns_scheduler/k_line/common/k_line_common_api.py +46 -2
- {mns_scheduler-1.3.3.0.dist-info → mns_scheduler-1.3.3.1.dist-info}/METADATA +1 -1
- {mns_scheduler-1.3.3.0.dist-info → mns_scheduler-1.3.3.1.dist-info}/RECORD +5 -5
- {mns_scheduler-1.3.3.0.dist-info → mns_scheduler-1.3.3.1.dist-info}/WHEEL +0 -0
- {mns_scheduler-1.3.3.0.dist-info → mns_scheduler-1.3.3.1.dist-info}/top_level.txt +0 -0
|
@@ -18,6 +18,7 @@ import mns_common.api.msg.push_msg_api as push_msg_api
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
import mns_common.utils.data_frame_util as data_frame_util
|
|
20
20
|
from loguru import logger
|
|
21
|
+
import threading
|
|
21
22
|
|
|
22
23
|
# source_type = 'xue_qiu'
|
|
23
24
|
source_type = 'xue_qiu'
|
|
@@ -29,14 +30,57 @@ def custom_alert(current: int, threshold: int):
|
|
|
29
30
|
push_msg_api.push_msg_to_wechat('获取k线数据异常', "当前次数:" + str(current) + "阈值:" + str(threshold))
|
|
30
31
|
|
|
31
32
|
|
|
33
|
+
# 定义一个带超时的函数调用
|
|
34
|
+
def call_with_timeout(func, *args, timeout=10, **kwargs):
|
|
35
|
+
# 用于存储函数执行结果
|
|
36
|
+
result = None
|
|
37
|
+
exception = None
|
|
38
|
+
|
|
39
|
+
# 定义一个线程目标函数
|
|
40
|
+
def target():
|
|
41
|
+
nonlocal result, exception
|
|
42
|
+
try:
|
|
43
|
+
result = func(*args, **kwargs)
|
|
44
|
+
except Exception as e:
|
|
45
|
+
exception = e
|
|
46
|
+
|
|
47
|
+
# 创建线程并启动
|
|
48
|
+
thread = threading.Thread(target=target)
|
|
49
|
+
thread.start()
|
|
50
|
+
|
|
51
|
+
# 等待线程完成,最多等待 timeout 秒
|
|
52
|
+
thread.join(timeout)
|
|
53
|
+
|
|
54
|
+
# 如果线程仍然存活,说明函数超时了
|
|
55
|
+
if thread.is_alive():
|
|
56
|
+
raise TimeoutError(f"Function exceeded timeout of {timeout} seconds")
|
|
57
|
+
|
|
58
|
+
# 如果函数抛出了异常,重新抛出
|
|
59
|
+
if exception is not None:
|
|
60
|
+
raise exception
|
|
61
|
+
return result
|
|
62
|
+
|
|
63
|
+
|
|
32
64
|
def get_k_line_common_adapter(symbol, period, hq, end_date):
|
|
33
65
|
global error_no
|
|
34
66
|
df = pd.DataFrame()
|
|
35
67
|
try:
|
|
36
68
|
if source_type == 'em':
|
|
37
|
-
|
|
69
|
+
|
|
70
|
+
df = call_with_timeout(get_em_k_line_api,
|
|
71
|
+
symbol,
|
|
72
|
+
period,
|
|
73
|
+
hq,
|
|
74
|
+
end_date,
|
|
75
|
+
timeout=10)
|
|
38
76
|
elif source_type == 'xue_qiu':
|
|
39
|
-
df = get_xueqiu_k_line_api
|
|
77
|
+
df = call_with_timeout(get_xueqiu_k_line_api,
|
|
78
|
+
symbol,
|
|
79
|
+
period,
|
|
80
|
+
hq,
|
|
81
|
+
end_date,
|
|
82
|
+
timeout=10)
|
|
83
|
+
|
|
40
84
|
if data_frame_util.is_empty(df):
|
|
41
85
|
error_no = error_no + 1
|
|
42
86
|
except BaseException as e:
|
|
@@ -79,7 +79,7 @@ mns_scheduler/k_line/clean/week_month/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3
|
|
|
79
79
|
mns_scheduler/k_line/clean/week_month/normal_week_month_k_line_service.py,sha256=n2osY8dozHClIlSOE7NR6S_oK_8GV-z72Az13D3fhCQ,10160
|
|
80
80
|
mns_scheduler/k_line/clean/week_month/sub_new_week_month_k_line_service.py,sha256=0rc2Rz_EoqoqpVvgPe4daCe09JtHBlJsQr1bMIlBQ2o,5526
|
|
81
81
|
mns_scheduler/k_line/common/__init__.py,sha256=itoGlqKhsx7EVXQoD1vchDKQ5GPB16vDjofTSuQtrXg,161
|
|
82
|
-
mns_scheduler/k_line/common/k_line_common_api.py,sha256=
|
|
82
|
+
mns_scheduler/k_line/common/k_line_common_api.py,sha256=9ep7-NyI_x2a1onTlmPg-R4VNx3yZ-IBQuhu1HgcBbM,7120
|
|
83
83
|
mns_scheduler/k_line/hot_stocks/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
84
84
|
mns_scheduler/k_line/hot_stocks/recent_hot_stocks_clean_service.py,sha256=8woZzGVORYX9KZr6xtfiYYgApDKissnzYM6hS2k6XBA,2628
|
|
85
85
|
mns_scheduler/k_line/month_week_daily/__init__.py,sha256=ffZXFCLFdIwOsbxnw__u1MbQYh9yz7Bs8UMP6VF0X2M,161
|
|
@@ -156,7 +156,7 @@ mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py,sha256=9Sv1G88poLG3_8aLPkfr8bdw
|
|
|
156
156
|
mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py,sha256=caW-MuF0RFLavJZafeLDYQ29-GxwGsmr5YVrN4lost8,2135
|
|
157
157
|
mns_scheduler/zz_task/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
158
158
|
mns_scheduler/zz_task/data_sync_task.py,sha256=18MI6OyWS97LvD_fj717St3gfJC4NNrA1lyKn_OteHc,23150
|
|
159
|
-
mns_scheduler-1.3.3.
|
|
160
|
-
mns_scheduler-1.3.3.
|
|
161
|
-
mns_scheduler-1.3.3.
|
|
162
|
-
mns_scheduler-1.3.3.
|
|
159
|
+
mns_scheduler-1.3.3.1.dist-info/METADATA,sha256=ekHl0bxT23RokfR1uT0g1mFOjueotLfaAROVTK4DQjw,64
|
|
160
|
+
mns_scheduler-1.3.3.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
161
|
+
mns_scheduler-1.3.3.1.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
|
|
162
|
+
mns_scheduler-1.3.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|