cobweb-launcher 1.2.1__py3-none-any.whl → 1.2.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 cobweb-launcher might be problematic. Click here for more details.
- cobweb/launchers/launcher.py +3 -2
- cobweb/launchers/launcher_pro.py +9 -35
- cobweb/setting.py +5 -0
- {cobweb_launcher-1.2.1.dist-info → cobweb_launcher-1.2.2.dist-info}/METADATA +1 -1
- {cobweb_launcher-1.2.1.dist-info → cobweb_launcher-1.2.2.dist-info}/RECORD +8 -8
- {cobweb_launcher-1.2.1.dist-info → cobweb_launcher-1.2.2.dist-info}/LICENSE +0 -0
- {cobweb_launcher-1.2.1.dist-info → cobweb_launcher-1.2.2.dist-info}/WHEEL +0 -0
- {cobweb_launcher-1.2.1.dist-info → cobweb_launcher-1.2.2.dist-info}/top_level.txt +0 -0
cobweb/launchers/launcher.py
CHANGED
|
@@ -40,6 +40,7 @@ class Launcher(threading.Thread):
|
|
|
40
40
|
self.task = task
|
|
41
41
|
self.project = project
|
|
42
42
|
|
|
43
|
+
self._app_time = int(time.time())
|
|
43
44
|
self._stop = threading.Event() # 结束事件
|
|
44
45
|
self._pause = threading.Event() # 暂停事件
|
|
45
46
|
|
|
@@ -65,6 +66,7 @@ class Launcher(threading.Thread):
|
|
|
65
66
|
self._Crawler = dynamic_load_class(setting.CRAWLER)
|
|
66
67
|
self._Pipeline = dynamic_load_class(setting.PIPELINE)
|
|
67
68
|
|
|
69
|
+
self._before_scheduler_wait_seconds = setting.BEFORE_SCHEDULER_WAIT_SECONDS
|
|
68
70
|
self._scheduler_wait_seconds = setting.SCHEDULER_WAIT_SECONDS
|
|
69
71
|
self._todo_queue_full_wait_seconds = setting.TODO_QUEUE_FULL_WAIT_SECONDS
|
|
70
72
|
self._new_queue_wait_seconds = setting.NEW_QUEUE_WAIT_SECONDS
|
|
@@ -83,7 +85,6 @@ class Launcher(threading.Thread):
|
|
|
83
85
|
self._done_model = setting.DONE_MODEL
|
|
84
86
|
self._task_model = setting.TASK_MODEL
|
|
85
87
|
|
|
86
|
-
# self._upload_queue = Queue()
|
|
87
88
|
|
|
88
89
|
@property
|
|
89
90
|
def start_seeds(self):
|
|
@@ -141,7 +142,7 @@ class Launcher(threading.Thread):
|
|
|
141
142
|
def _execute(self):
|
|
142
143
|
for func_name in self.__LAUNCHER_FUNC__:
|
|
143
144
|
threading.Thread(name=func_name, target=getattr(self, func_name)).start()
|
|
144
|
-
time.sleep(
|
|
145
|
+
time.sleep(1)
|
|
145
146
|
|
|
146
147
|
def run(self):
|
|
147
148
|
threading.Thread(target=self._execute_heartbeat).start()
|
cobweb/launchers/launcher_pro.py
CHANGED
|
@@ -137,6 +137,7 @@ class LauncherPro(Launcher):
|
|
|
137
137
|
time.sleep(self._done_queue_wait_seconds)
|
|
138
138
|
|
|
139
139
|
def _polling(self):
|
|
140
|
+
wait_scheduler_execute = True
|
|
140
141
|
check_emtpy_times = 0
|
|
141
142
|
while not self._stop.is_set():
|
|
142
143
|
queue_not_empty_count = 0
|
|
@@ -145,14 +146,19 @@ class LauncherPro(Launcher):
|
|
|
145
146
|
for q in self.__LAUNCHER_QUEUE__.values():
|
|
146
147
|
if q.length != 0:
|
|
147
148
|
queue_not_empty_count += 1
|
|
149
|
+
wait_scheduler_execute = False
|
|
148
150
|
|
|
149
151
|
if queue_not_empty_count == 0:
|
|
150
152
|
pooling_wait_seconds = 3
|
|
151
153
|
if self._pause.is_set():
|
|
152
154
|
check_emtpy_times = 0
|
|
153
|
-
if not self._task_model
|
|
155
|
+
if not self._task_model and (
|
|
156
|
+
not wait_scheduler_execute or
|
|
157
|
+
int(time.time()) - self._app_time > self._before_scheduler_wait_seconds
|
|
158
|
+
):
|
|
154
159
|
logger.info("Done! ready to close thread...")
|
|
155
160
|
self._stop.set()
|
|
161
|
+
|
|
156
162
|
elif self._db.zcount(self._todo_key, _min=0, _max="(1000"):
|
|
157
163
|
logger.info(f"Recovery {self.task} task run!")
|
|
158
164
|
self._pause.clear()
|
|
@@ -161,16 +167,14 @@ class LauncherPro(Launcher):
|
|
|
161
167
|
logger.info("pause! waiting for resume...")
|
|
162
168
|
elif check_emtpy_times > 2:
|
|
163
169
|
self.__DOING__ = {}
|
|
164
|
-
self.
|
|
170
|
+
if not self._db.zcount(self._todo_key, _min="-inf", _max="(1000"):
|
|
171
|
+
self._pause.set()
|
|
165
172
|
else:
|
|
166
173
|
logger.info(
|
|
167
174
|
"check whether the task is complete, "
|
|
168
175
|
f"reset times {3 - check_emtpy_times}"
|
|
169
176
|
)
|
|
170
177
|
check_emtpy_times += 1
|
|
171
|
-
# elif self._pause.is_set():
|
|
172
|
-
# self._pause.clear()
|
|
173
|
-
# self._execute()
|
|
174
178
|
else:
|
|
175
179
|
logger.info(LogTemplate.launcher_pro_polling.format(
|
|
176
180
|
task=self.task,
|
|
@@ -184,36 +188,6 @@ class LauncherPro(Launcher):
|
|
|
184
188
|
))
|
|
185
189
|
|
|
186
190
|
time.sleep(pooling_wait_seconds)
|
|
187
|
-
# if self._pause.is_set():
|
|
188
|
-
# self._pause.clear()
|
|
189
|
-
# self._execute()
|
|
190
|
-
#
|
|
191
|
-
# elif queue_not_empty_count == 0:
|
|
192
|
-
# pooling_wait_seconds = 5
|
|
193
|
-
# check_emtpy_times += 1
|
|
194
|
-
# else:
|
|
195
|
-
# check_emtpy_times = 0
|
|
196
|
-
#
|
|
197
|
-
# if not self._db.zcount(self._todo, _min=0, _max="(1000") and check_emtpy_times > 2:
|
|
198
|
-
# check_emtpy_times = 0
|
|
199
|
-
# self.__DOING__ = {}
|
|
200
|
-
# self._pause.set()
|
|
201
|
-
#
|
|
202
|
-
# time.sleep(pooling_wait_seconds)
|
|
203
|
-
#
|
|
204
|
-
# if not self._pause.is_set():
|
|
205
|
-
# logger.info(LogTemplate.launcher_pro_polling.format(
|
|
206
|
-
# task=self.task,
|
|
207
|
-
# doing_len=len(self.__DOING__.keys()),
|
|
208
|
-
# todo_len=self.__LAUNCHER_QUEUE__['todo'].length,
|
|
209
|
-
# done_len=self.__LAUNCHER_QUEUE__['done'].length,
|
|
210
|
-
# redis_seed_count=self._db.zcount(self._todo, "-inf", "+inf"),
|
|
211
|
-
# redis_todo_len=self._db.zcount(self._todo, 0, "(1000"),
|
|
212
|
-
# redis_doing_len=self._db.zcount(self._todo, "-inf", "(0"),
|
|
213
|
-
# upload_len=self.__LAUNCHER_QUEUE__['upload'].length,
|
|
214
|
-
# ))
|
|
215
|
-
# elif not self._task_model:
|
|
216
|
-
# self._stop.set()
|
|
217
191
|
|
|
218
192
|
logger.info("Done! Ready to close thread...")
|
|
219
193
|
|
cobweb/setting.py
CHANGED
|
@@ -26,6 +26,9 @@ OSS_SECRET_KEY = os.getenv("OSS_SECRET_KEY")
|
|
|
26
26
|
OSS_CHUNK_SIZE = 10 * 1024 ** 2
|
|
27
27
|
OSS_MIN_UPLOAD_SIZE = 1024
|
|
28
28
|
|
|
29
|
+
# message
|
|
30
|
+
MESSAGE = ""
|
|
31
|
+
|
|
29
32
|
|
|
30
33
|
# 采集器选择
|
|
31
34
|
CRAWLER = "cobweb.crawlers.Crawler"
|
|
@@ -35,6 +38,8 @@ PIPELINE = "cobweb.pipelines.pipeline_console.Console"
|
|
|
35
38
|
|
|
36
39
|
|
|
37
40
|
# Launcher 等待时间
|
|
41
|
+
|
|
42
|
+
BEFORE_SCHEDULER_WAIT_SECONDS = 60 # 调度前等待时间,只作用于单次任务
|
|
38
43
|
SCHEDULER_WAIT_SECONDS = 15 # 调度等待时间
|
|
39
44
|
TODO_QUEUE_FULL_WAIT_SECONDS = 5 # todo队列已满时等待时间
|
|
40
45
|
NEW_QUEUE_WAIT_SECONDS = 30 # new队列等待时间
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cobweb/__init__.py,sha256=uMHyf4Fekbyw2xBCbkA8R0LwCpBJf5p_7pWbh60ZWYk,83
|
|
2
2
|
cobweb/constant.py,sha256=zy3XYsc1qp2B76_Fn_hVQ8eGHlPBd3OFlZK2cryE6FY,2839
|
|
3
|
-
cobweb/setting.py,sha256=
|
|
3
|
+
cobweb/setting.py,sha256=_t3LMSpxUNR4dVD9Tox22W9omHPvjeWABFzpgkEOoH0,2016
|
|
4
4
|
cobweb/base/__init__.py,sha256=4gwWWQ0Q8cYG9cD7Lwf4XMqRGc5M_mapS3IczR6zeCE,222
|
|
5
5
|
cobweb/base/common_queue.py,sha256=W7PPZZFl52j3Mc916T0imHj7oAUelA6aKJwW-FecDPE,872
|
|
6
6
|
cobweb/base/decorators.py,sha256=wDCaQ94aAZGxks9Ljc0aXq6omDXT1_yzFy83ZW6VbVI,930
|
|
@@ -18,9 +18,9 @@ cobweb/db/redis_db.py,sha256=NNI2QkRV1hEZI-z-COEncXt88z3pZN6wusKlcQzc8V4,4304
|
|
|
18
18
|
cobweb/exceptions/__init__.py,sha256=E9SHnJBbhD7fOgPFMswqyOf8SKRDrI_i25L0bSpohvk,32
|
|
19
19
|
cobweb/exceptions/oss_db_exception.py,sha256=iP_AImjNHT3-Iv49zCFQ3rdLnlvuHa3h2BXApgrOYpA,636
|
|
20
20
|
cobweb/launchers/__init__.py,sha256=af0Y6wrGX8SQZ7w7XL2sOtREjCT3dwad-uCc3nIontY,76
|
|
21
|
-
cobweb/launchers/launcher.py,sha256=
|
|
21
|
+
cobweb/launchers/launcher.py,sha256=Mepg-hv9YL5_VnY_Mwqxzd8ZRGyK8gxsl_5B_Ibz0Uc,5466
|
|
22
22
|
cobweb/launchers/launcher_air.py,sha256=zHVEJqQCxYU1WDnqQzzEHbEXasR1GmKevujQkCfFt5o,2947
|
|
23
|
-
cobweb/launchers/launcher_pro.py,sha256=
|
|
23
|
+
cobweb/launchers/launcher_pro.py,sha256=ihsEcdP8iOrJhHzQTYQow-8pIYK3CCn-iwwI3v9UzMw,7727
|
|
24
24
|
cobweb/pipelines/__init__.py,sha256=zSUsGtx6smbs2iXBXvYynReKSgky-3gjqaAtKVnA_OU,105
|
|
25
25
|
cobweb/pipelines/base_pipeline.py,sha256=fYnWf79GmhufXpcnMa3te18SbmnVeYLwxfyo-zLd9CY,1577
|
|
26
26
|
cobweb/pipelines/loghub_pipeline.py,sha256=cjPO6w6UJ0jNw2fVvdX0BCdlm58T7dmYXlxzXOBpvfY,1027
|
|
@@ -30,8 +30,8 @@ cobweb/pipelines/pipeline_loghub.py,sha256=xZ6D55BGdiM71WUv83jyLGbEyUwhBHLJRZoXt
|
|
|
30
30
|
cobweb/utils/__init__.py,sha256=JTE4sBfHnKHhD6w9Auk0MIT7O9BMOamCeryhlHNx3Zg,47
|
|
31
31
|
cobweb/utils/oss.py,sha256=gyt8-UB07tVphZLQXMOf-JTJwU-mWq8KZkOXKkAf3uk,3513
|
|
32
32
|
cobweb/utils/tools.py,sha256=5JEaaAwYoV9Sdla2UBIJn6faUBuXmxUMagm9ck6FVqs,1253
|
|
33
|
-
cobweb_launcher-1.2.
|
|
34
|
-
cobweb_launcher-1.2.
|
|
35
|
-
cobweb_launcher-1.2.
|
|
36
|
-
cobweb_launcher-1.2.
|
|
37
|
-
cobweb_launcher-1.2.
|
|
33
|
+
cobweb_launcher-1.2.2.dist-info/LICENSE,sha256=z1rxSIGOyzcSb3orZxFPxzx-0C1vTocmswqBNxpKfEk,1063
|
|
34
|
+
cobweb_launcher-1.2.2.dist-info/METADATA,sha256=nMfaL4ItGVnr9tHtxNnBEGud1HI_ZRbIGqmfL4TnV7o,6489
|
|
35
|
+
cobweb_launcher-1.2.2.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
|
36
|
+
cobweb_launcher-1.2.2.dist-info/top_level.txt,sha256=4GETBGNsKqiCUezmT-mJn7tjhcDlu7nLIV5gGgHBW4I,7
|
|
37
|
+
cobweb_launcher-1.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|