cobweb-launcher 1.1.5__py3-none-any.whl → 1.1.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 cobweb-launcher might be problematic. Click here for more details.

@@ -123,12 +123,14 @@ class FileCrawlerPro(Crawler):
123
123
  item.seed, response, filter=True, msg=f"response content type is {content_type}",
124
124
  bucket_name=bucket_name, data_size=content_length, **seed_dict
125
125
  )
126
+ response.close()
126
127
  elif position == 1 and min_upload_size >= content_length > 0:
127
128
  """过小文件标识返回"""
128
129
  yield Response(
129
130
  item.seed, response, filter=True, msg="file size is too small",
130
131
  bucket_name=bucket_name, data_size=content_length, **seed_dict
131
132
  )
133
+ response.close()
132
134
  elif position == 1 and chunk_size > content_length > min_upload_size:
133
135
  """小文件直接下载"""
134
136
  for part_data in response.iter_content(chunk_size):
@@ -153,12 +155,12 @@ class FileCrawlerPro(Crawler):
153
155
  seed_dict['position'] = position
154
156
  seed_dict['start'] = upload_content_length
155
157
 
156
- response.close()
157
158
  if content:
158
159
  oss_util.put_part(key, upload_id, position, content)
159
160
  content_length += len(content)
160
161
  oss_util.merge(key, upload_id)
161
162
  yield Response(item.seed, response, bucket_name=bucket_name, data_size=content_length, **seed_dict)
163
+ response.close()
162
164
 
163
165
  elif item.seed.params.identifier == "merge":
164
166
  oss_util.merge(key, seed_dict["upload_id"])
@@ -34,7 +34,7 @@ class Launcher(threading.Thread):
34
34
  "_delete",
35
35
  ]
36
36
 
37
- def __init__(self, task, project, custom_setting=None):
37
+ def __init__(self, task, project, custom_setting=None, **kwargs):
38
38
  super().__init__()
39
39
  self.task = task
40
40
  self.project = project
@@ -42,10 +42,11 @@ class Launcher(threading.Thread):
42
42
  self._stop = threading.Event() # 结束事件
43
43
  self._pause = threading.Event() # 暂停事件
44
44
 
45
+ _setting = dict()
46
+
45
47
  if custom_setting:
46
- setting_ = dict()
47
48
  if isinstance(custom_setting, dict):
48
- setting_ = custom_setting
49
+ _setting = custom_setting
49
50
  else:
50
51
  if isinstance(custom_setting, str):
51
52
  custom_setting = importlib.import_module(custom_setting)
@@ -53,9 +54,12 @@ class Launcher(threading.Thread):
53
54
  raise Exception
54
55
  for k, v in custom_setting.__dict__.items():
55
56
  if not k.startswith("__") and not inspect.ismodule(v):
56
- setting_[k] = v
57
- for k, v in setting_.items():
58
- setattr(setting, k, v)
57
+ _setting[k] = v
58
+
59
+ _setting.update(**kwargs)
60
+
61
+ for k, v in _setting.items():
62
+ setattr(setting, k, v)
59
63
 
60
64
  self._Crawler = dynamic_load_class(setting.CRAWLER)
61
65
  self._Pipeline = dynamic_load_class(setting.PIPELINE)
@@ -9,8 +9,8 @@ from cobweb.constant import DealModel, LogTemplate
9
9
 
10
10
  class LauncherPro(Launcher):
11
11
 
12
- def __init__(self, task, project, custom_setting=None):
13
- super().__init__(task, project, custom_setting)
12
+ def __init__(self, task, project, custom_setting=None, **kwargs):
13
+ super().__init__(task, project, custom_setting, **kwargs)
14
14
  self._todo = "{%s:%s}:todo" % (project, task)
15
15
  self._done = "{%s:%s}:done" % (project, task)
16
16
  self._fail = "{%s:%s}:fail" % (project, task)
@@ -140,22 +140,23 @@ class LauncherPro(Launcher):
140
140
  while not self._stop.is_set():
141
141
  queue_not_empty_count = 0
142
142
  pooling_wait_seconds = 30
143
- if not self._db.zcard(self._todo):
144
- for q in self.__LAUNCHER_QUEUE__.values():
145
- if q.length != 0:
146
- queue_not_empty_count += 1
147
- if self._pause.is_set():
148
- self._pause.clear()
149
- self._execute()
150
- elif queue_not_empty_count == 0:
151
- pooling_wait_seconds = 3
152
- check_emtpy_times += 1
153
- else:
154
- check_emtpy_times = 0
155
- if check_emtpy_times > 2:
156
- check_emtpy_times = 0
157
- self.__DOING__ = {}
158
- self._pause.set()
143
+ for q in self.__LAUNCHER_QUEUE__.values():
144
+ if q.length != 0:
145
+ queue_not_empty_count += 1
146
+ if self._pause.is_set():
147
+ self._pause.clear()
148
+ self._execute()
149
+ elif queue_not_empty_count == 0:
150
+ pooling_wait_seconds = 5
151
+ check_emtpy_times += 1
152
+ else:
153
+ check_emtpy_times = 0
154
+
155
+ if not self._db.zcount(self._todo, _min=0, _max="(1000") and check_emtpy_times > 2:
156
+ check_emtpy_times = 0
157
+ self.__DOING__ = {}
158
+ self._pause.set()
159
+
159
160
  if not self._pause.is_set():
160
161
  logger.info(LogTemplate.launcher_pro_polling.format(
161
162
  task=self.task,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cobweb-launcher
3
- Version: 1.1.5
3
+ Version: 1.1.9
4
4
  Summary: spider_hole
5
5
  Home-page: https://github.com/Juannie-PP/cobweb
6
6
  Author: Juannie-PP
@@ -11,22 +11,22 @@ cobweb/base/response.py,sha256=7h9TwCNqRlwM_fvNmid9zOoRfHbKB8ABSU0eaVUJdVo,405
11
11
  cobweb/base/seed.py,sha256=XswH16eEd6iwIBpt71E2S_AsV5UVCcOEOBFoP0r5QRo,2900
12
12
  cobweb/crawlers/__init__.py,sha256=_HAXBg7Sq8fsDGSjDm3AQz9aQtLZONpt5b8dSe607mI,91
13
13
  cobweb/crawlers/base_crawler.py,sha256=uR1wQ2sJpFovNoAK52293rF03O-jNbv24P5QoNt1tW0,5169
14
- cobweb/crawlers/file_crawler.py,sha256=LTiHaxhEiJyiAGgodO3an8AYf_y88AeMoFcKae3Vx_M,8381
14
+ cobweb/crawlers/file_crawler.py,sha256=Lr0-eQJlQcgHaojOM5-awcIAJOUi9eZ_E1XOTYuQM28,8455
15
15
  cobweb/db/__init__.py,sha256=ut0iEyBLjcJL06WNG_5_d4hO5PJWvDrKWMkDOdmgh2M,30
16
16
  cobweb/db/redis_db.py,sha256=NNI2QkRV1hEZI-z-COEncXt88z3pZN6wusKlcQzc8V4,4304
17
17
  cobweb/exceptions/__init__.py,sha256=E9SHnJBbhD7fOgPFMswqyOf8SKRDrI_i25L0bSpohvk,32
18
18
  cobweb/exceptions/oss_db_exception.py,sha256=iP_AImjNHT3-Iv49zCFQ3rdLnlvuHa3h2BXApgrOYpA,636
19
19
  cobweb/launchers/__init__.py,sha256=qwlkEJVri7dvCgi45aX3lqAmQS0HrPicAipDvH75kew,69
20
- cobweb/launchers/launcher.py,sha256=O6Kkvqk-0kOxJom8YO9zW18e_2eMYrA5RTS9Xy4TW5k,5665
21
- cobweb/launchers/launcher_pro.py,sha256=3B7JjT2wk-q_Q9yCIw36OIS0eGVNBFRV5F6WLzH4FKo,6620
20
+ cobweb/launchers/launcher.py,sha256=s4PSfcjYiMiboSB_yEOS68NSMBBE7VW5BY3WzPLxq1w,5700
21
+ cobweb/launchers/launcher_pro.py,sha256=T4mgSBqFkbU64EF6Fo_oMxzWldD_-l0rC-zFEZxqBQU,6593
22
22
  cobweb/pipelines/__init__.py,sha256=xanY-Z1d7zRR5JhCdW2htzrAywnKBkigiaUlTFa6of0,80
23
23
  cobweb/pipelines/base_pipeline.py,sha256=fYnWf79GmhufXpcnMa3te18SbmnVeYLwxfyo-zLd9CY,1577
24
24
  cobweb/pipelines/loghub_pipeline.py,sha256=cjPO6w6UJ0jNw2fVvdX0BCdlm58T7dmYXlxzXOBpvfY,1027
25
25
  cobweb/utils/__init__.py,sha256=JTE4sBfHnKHhD6w9Auk0MIT7O9BMOamCeryhlHNx3Zg,47
26
26
  cobweb/utils/oss.py,sha256=uD5aN2oVYImit3amE6TjxWMaTAcbAh9dCnpIQhf4M9Q,3238
27
27
  cobweb/utils/tools.py,sha256=bVd3iRGBvwhohQAH7AXTTjbmQ54Z35K0O-fatEyhePU,1249
28
- cobweb_launcher-1.1.5.dist-info/LICENSE,sha256=z1rxSIGOyzcSb3orZxFPxzx-0C1vTocmswqBNxpKfEk,1063
29
- cobweb_launcher-1.1.5.dist-info/METADATA,sha256=F5vvm0pngBeivTOVQ_srp-7epa3gHadaovtottKAIko,1245
30
- cobweb_launcher-1.1.5.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
31
- cobweb_launcher-1.1.5.dist-info/top_level.txt,sha256=4GETBGNsKqiCUezmT-mJn7tjhcDlu7nLIV5gGgHBW4I,7
32
- cobweb_launcher-1.1.5.dist-info/RECORD,,
28
+ cobweb_launcher-1.1.9.dist-info/LICENSE,sha256=z1rxSIGOyzcSb3orZxFPxzx-0C1vTocmswqBNxpKfEk,1063
29
+ cobweb_launcher-1.1.9.dist-info/METADATA,sha256=BmlL5uOSiwZxO-aeZXHrmAjc_DV0rnK2HljaASlBE8w,1245
30
+ cobweb_launcher-1.1.9.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
31
+ cobweb_launcher-1.1.9.dist-info/top_level.txt,sha256=4GETBGNsKqiCUezmT-mJn7tjhcDlu7nLIV5gGgHBW4I,7
32
+ cobweb_launcher-1.1.9.dist-info/RECORD,,