cobweb-launcher 1.2.50__py3-none-any.whl → 1.2.51__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.

@@ -100,6 +100,7 @@ class Launcher(threading.Thread):
100
100
  self._spider_time_sleep = setting.SPIDER_TIME_SLEEP
101
101
  self._spider_max_count = setting.SPIDER_MAX_COUNT
102
102
  self._time_window = setting.TIME_WINDOW
103
+ self._speed_control = setting.SPEED_CONTROL
103
104
 
104
105
  self._done_model = setting.DONE_MODEL
105
106
  self._task_model = setting.TASK_MODEL
@@ -46,7 +46,7 @@ class LauncherApi(Launcher):
46
46
  设置时间窗口为self._time_window(秒),判断在该窗口内的采集量是否满足阈值(self._spider_max_speed)
47
47
  :return: True -> 种子, False -> None
48
48
  """
49
- if (self.__LAUNCHER_QUEUE__["todo"].length and
49
+ if (self._speed_control and self.__LAUNCHER_QUEUE__["todo"].length and
50
50
  not self._db.auto_incr(self._speed_control_key, t=self._time_window, limit=self._spider_max_count)):
51
51
  expire_time = self._db.ttl(self._speed_control_key)
52
52
  logger.info(f"Too fast! Please wait {expire_time} seconds...")
@@ -3,7 +3,7 @@ import threading
3
3
 
4
4
  from cobweb.db import RedisDB
5
5
  from cobweb.base import Seed, logger
6
- from cobweb.utils import BloomFilter
6
+ # from cobweb.utils import BloomFilter
7
7
  from cobweb.constant import DealModel, LogTemplate
8
8
  from .launcher import Launcher, check_pause
9
9
 
@@ -43,17 +43,18 @@ class LauncherPro(Launcher):
43
43
  self._db._client.incrby(key, count)
44
44
 
45
45
  def _get_seed(self) -> Seed:
46
- spider_speed = self._db._client.get(self._speed_control_key)
47
- if int(spider_speed or 0) > self._spider_max_count:
48
- expire_time = self._db.ttl(self._speed_control_key)
49
- if expire_time == -1:
50
- self._db.delete(self._speed_control_key)
51
- else:
52
- logger.info(f"Too fast! Please wait {expire_time} seconds...")
53
- time.sleep(expire_time / 2)
54
- return None
46
+ if self._speed_control:
47
+ spider_speed = self._db._client.get(self._speed_control_key)
48
+ if int(spider_speed or 0) > self._spider_max_count:
49
+ expire_time = self._db.ttl(self._speed_control_key)
50
+ if expire_time == -1:
51
+ self._db.delete(self._speed_control_key)
52
+ else:
53
+ logger.info(f"Too fast! Please wait {expire_time} seconds...")
54
+ time.sleep(expire_time / 2)
55
+ return None
55
56
  seed = self.__LAUNCHER_QUEUE__["todo"].pop()
56
- if seed and not self._db.lock(self._speed_control_key, t=self._time_window):
57
+ if self._speed_control and seed and not self._db.lock(self._speed_control_key, t=self._time_window):
57
58
  self._db._client.incrby(self._speed_control_key, 1)
58
59
  return seed
59
60
 
cobweb/setting.py CHANGED
@@ -65,6 +65,8 @@ TIME_WINDOW = 60 # 频控固定时间窗口(秒)
65
65
  # 任务模式
66
66
  TASK_MODEL = 0 # 0:单次,1:常驻
67
67
 
68
+ # 流控措施
69
+ SPEED_CONTROL = 1 # 0:关闭,1:开启
68
70
 
69
71
  # bloom过滤器
70
72
  CAPACITY = 100000000
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cobweb-launcher
3
- Version: 1.2.50
3
+ Version: 1.2.51
4
4
  Summary: spider_hole
5
5
  Home-page: https://github.com/Juannie-PP/cobweb
6
6
  Author: Juannie-PP
@@ -1,6 +1,6 @@
1
1
  cobweb/__init__.py,sha256=CBd2oByCfc5EmH2dCZYVHkxXYZG-oWrLyTtZU5sEoP0,96
2
2
  cobweb/constant.py,sha256=zy3XYsc1qp2B76_Fn_hVQ8eGHlPBd3OFlZK2cryE6FY,2839
3
- cobweb/setting.py,sha256=47HZsw40HLpsmOmvij1lyQALPQQCN_tWlKZ0wbn2MtM,2216
3
+ cobweb/setting.py,sha256=JHRrVQL22iidkNe8seQTuxK3hlTdtnvb6VBVygpMs5I,2272
4
4
  cobweb/base/__init__.py,sha256=4gwWWQ0Q8cYG9cD7Lwf4XMqRGc5M_mapS3IczR6zeCE,222
5
5
  cobweb/base/basic.py,sha256=Z56SSLB3I2IGHWCCcSy0Qbfzj8Qbg_po3gP32q1jh4k,7741
6
6
  cobweb/base/common_queue.py,sha256=W7PPZZFl52j3Mc916T0imHj7oAUelA6aKJwW-FecDPE,872
@@ -21,10 +21,10 @@ cobweb/db/redis_db.py,sha256=fumNZJiio-uQqRcSrymx8eJ1PqsdOwITe_Y-9JOXxrQ,4298
21
21
  cobweb/exceptions/__init__.py,sha256=E9SHnJBbhD7fOgPFMswqyOf8SKRDrI_i25L0bSpohvk,32
22
22
  cobweb/exceptions/oss_db_exception.py,sha256=iP_AImjNHT3-Iv49zCFQ3rdLnlvuHa3h2BXApgrOYpA,636
23
23
  cobweb/launchers/__init__.py,sha256=qMuVlQcjErVK67HyKFZEsXf_rfZD5ODjx1QucSCKMOM,114
24
- cobweb/launchers/launcher.py,sha256=sPts-xlgxoeIfl1fn1XR2XVZxLzt7He9xrYDfTHRAGo,7029
24
+ cobweb/launchers/launcher.py,sha256=_qC3EnD_QxQRP_RBNHHJ8HLfn_0FED1jUF_lyas5Hss,7081
25
25
  cobweb/launchers/launcher_air.py,sha256=KAk_M8F3029cXYe7m4nn3Nzyi89lbxJ2cqZjqW8iZ0E,2832
26
- cobweb/launchers/launcher_api.py,sha256=YFqCTRvKn6icBLWTR1VxkU0WEIte2F7fv_LgPkifqdo,7885
27
- cobweb/launchers/launcher_pro.py,sha256=B5FdxvuENRL3XrMl74ENdP1uNgnZOaYCUUfBfM0t3io,7842
26
+ cobweb/launchers/launcher_api.py,sha256=7K7Kl3dk7Ung9iRBwhiMrALEJywcR66ie5RIkLQEM-Y,7909
27
+ cobweb/launchers/launcher_pro.py,sha256=QMumHUTi6IudO5mw9SnwlmP8k_BJ50cpNjYjoQv-_YY,7936
28
28
  cobweb/pipelines/__init__.py,sha256=zSUsGtx6smbs2iXBXvYynReKSgky-3gjqaAtKVnA_OU,105
29
29
  cobweb/pipelines/pipeline.py,sha256=4TJLX0sUHRxYndF5A4Vs5btUGI-wigkOcFvhTW1hLXI,2009
30
30
  cobweb/pipelines/pipeline_console.py,sha256=NEh-4zhuVAQOqwXLsqeb-rcNZ9_KXFUpL3otUTL5qBs,754
@@ -37,8 +37,8 @@ cobweb/utils/bloom.py,sha256=vng-YbKgh9HbtpAWYf_nkUSbfVTOj40aqUUejRYlsCU,1752
37
37
  cobweb/utils/dotting.py,sha256=mVICaa26R-dQ4JGmPK-kkR6QjX38QiRewXZnGb2DCIc,1784
38
38
  cobweb/utils/oss.py,sha256=gyt8-UB07tVphZLQXMOf-JTJwU-mWq8KZkOXKkAf3uk,3513
39
39
  cobweb/utils/tools.py,sha256=5JEaaAwYoV9Sdla2UBIJn6faUBuXmxUMagm9ck6FVqs,1253
40
- cobweb_launcher-1.2.50.dist-info/LICENSE,sha256=z1rxSIGOyzcSb3orZxFPxzx-0C1vTocmswqBNxpKfEk,1063
41
- cobweb_launcher-1.2.50.dist-info/METADATA,sha256=uOO7AE9213AnlsYh-hhW2lCT_3-v9vaA7gmgiC1diuA,6510
42
- cobweb_launcher-1.2.50.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
43
- cobweb_launcher-1.2.50.dist-info/top_level.txt,sha256=4GETBGNsKqiCUezmT-mJn7tjhcDlu7nLIV5gGgHBW4I,7
44
- cobweb_launcher-1.2.50.dist-info/RECORD,,
40
+ cobweb_launcher-1.2.51.dist-info/LICENSE,sha256=z1rxSIGOyzcSb3orZxFPxzx-0C1vTocmswqBNxpKfEk,1063
41
+ cobweb_launcher-1.2.51.dist-info/METADATA,sha256=xzLg7vLTsWurDo9L8jjmnlq-8B6UE1bT2itXPHt4a8o,6510
42
+ cobweb_launcher-1.2.51.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
43
+ cobweb_launcher-1.2.51.dist-info/top_level.txt,sha256=4GETBGNsKqiCUezmT-mJn7tjhcDlu7nLIV5gGgHBW4I,7
44
+ cobweb_launcher-1.2.51.dist-info/RECORD,,