cobweb-launcher 3.1.8__tar.gz → 3.1.10__tar.gz
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.
- {cobweb-launcher-3.1.8/cobweb_launcher.egg-info → cobweb-launcher-3.1.10}/PKG-INFO +1 -1
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/launchers/launcher.py +2 -2
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/schedulers/scheduler_with_redis.py +1 -2
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/utils/__init__.py +1 -1
- cobweb-launcher-3.1.10/cobweb/utils/oss.py +113 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10/cobweb_launcher.egg-info}/PKG-INFO +1 -1
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/setup.py +1 -1
- cobweb-launcher-3.1.8/cobweb/utils/oss.py +0 -113
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/LICENSE +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/README.md +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/__init__.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/base/__init__.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/base/common_queue.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/base/item.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/base/log.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/base/request.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/base/response.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/base/seed.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/constant.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/crawlers/__init__.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/crawlers/crawler.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/db/__init__.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/db/api_db.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/db/redis_db.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/exceptions/__init__.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/exceptions/oss_db_exception.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/launchers/__init__.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/launchers/distributor.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/launchers/uploader.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/pipelines/__init__.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/pipelines/pipeline.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/pipelines/pipeline_console.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/pipelines/pipeline_loghub.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/schedulers/__init__.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/schedulers/scheduler.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/setting.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/utils/bloom.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/utils/decorators.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/utils/dotting.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb/utils/tools.py +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb_launcher.egg-info/SOURCES.txt +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb_launcher.egg-info/dependency_links.txt +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb_launcher.egg-info/requires.txt +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb_launcher.egg-info/top_level.txt +0 -0
- {cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/setup.cfg +0 -0
@@ -120,7 +120,7 @@ class Launcher:
|
|
120
120
|
if self._pause.is_set():
|
121
121
|
time.sleep(15)
|
122
122
|
continue
|
123
|
-
for name, worker_thread in self.__WORKER_THREAD__.items():
|
123
|
+
for name, worker_thread in list(self.__WORKER_THREAD__.items()):
|
124
124
|
if not worker_thread.is_alive():
|
125
125
|
logger.info(f"{name} thread is dead. Restarting...")
|
126
126
|
func = self.__REGISTER_FUNC__[name]
|
@@ -128,7 +128,7 @@ class Launcher:
|
|
128
128
|
self.__WORKER_THREAD__[name] = worker_thread
|
129
129
|
worker_thread.start()
|
130
130
|
time.sleep(3)
|
131
|
-
logger.info("
|
131
|
+
logger.info("main thread close!")
|
132
132
|
|
133
133
|
def start(self):
|
134
134
|
self._pause.is_set()
|
@@ -147,7 +147,6 @@ class RedisScheduler(Scheduler):
|
|
147
147
|
elif todo_count:
|
148
148
|
logger.info(f"Recovery {self.task} task run!todo seeds count: {todo_count}, queue length: {all_count}")
|
149
149
|
self.pause.clear()
|
150
|
-
# self.execute()
|
151
150
|
else:
|
152
151
|
logger.info("pause! waiting for resume...")
|
153
152
|
else:
|
@@ -173,5 +172,5 @@ class RedisScheduler(Scheduler):
|
|
173
172
|
|
174
173
|
time.sleep(30)
|
175
174
|
|
176
|
-
logger.info("Done!
|
175
|
+
logger.info("Scheduler Done!")
|
177
176
|
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#
|
2
|
+
# from cobweb import setting
|
3
|
+
# from requests import Response
|
4
|
+
# from oss2 import Auth, Bucket, models, PartIterator
|
5
|
+
# from cobweb.exceptions import oss_db_exception
|
6
|
+
# from cobweb.utils.decorators import decorator_oss_db
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# class OssUtil:
|
10
|
+
#
|
11
|
+
# def __init__(
|
12
|
+
# self,
|
13
|
+
# bucket=None,
|
14
|
+
# endpoint=None,
|
15
|
+
# access_key=None,
|
16
|
+
# secret_key=None,
|
17
|
+
# chunk_size=None,
|
18
|
+
# min_upload_size=None,
|
19
|
+
# **kwargs
|
20
|
+
# ):
|
21
|
+
# self.bucket = bucket or setting.OSS_BUCKET
|
22
|
+
# self.endpoint = endpoint or setting.OSS_ENDPOINT
|
23
|
+
# self.chunk_size = int(chunk_size or setting.OSS_CHUNK_SIZE)
|
24
|
+
# self.min_upload_size = int(min_upload_size or setting.OSS_MIN_UPLOAD_SIZE)
|
25
|
+
#
|
26
|
+
# self.failed_count = 0
|
27
|
+
# self._kw = kwargs
|
28
|
+
#
|
29
|
+
# self._auth = Auth(
|
30
|
+
# access_key_id=access_key or setting.OSS_ACCESS_KEY,
|
31
|
+
# access_key_secret=secret_key or setting.OSS_SECRET_KEY
|
32
|
+
# )
|
33
|
+
# self._client = Bucket(
|
34
|
+
# auth=self._auth,
|
35
|
+
# endpoint=self.endpoint,
|
36
|
+
# bucket_name=self.bucket,
|
37
|
+
# **self._kw
|
38
|
+
# )
|
39
|
+
#
|
40
|
+
# def failed(self):
|
41
|
+
# self.failed_count += 1
|
42
|
+
# if self.failed_count >= 5:
|
43
|
+
# self._client = Bucket(
|
44
|
+
# auth=self._auth,
|
45
|
+
# endpoint=self.endpoint,
|
46
|
+
# bucket_name=self.bucket,
|
47
|
+
# **self._kw
|
48
|
+
# )
|
49
|
+
#
|
50
|
+
# def exists(self, key: str) -> bool:
|
51
|
+
# try:
|
52
|
+
# result = self._client.object_exists(key)
|
53
|
+
# self.failed_count = 0
|
54
|
+
# return result
|
55
|
+
# except Exception as e:
|
56
|
+
# self.failed()
|
57
|
+
# raise e
|
58
|
+
#
|
59
|
+
# def head(self, key: str) -> models.HeadObjectResult:
|
60
|
+
# return self._client.head_object(key)
|
61
|
+
#
|
62
|
+
# @decorator_oss_db(exception=oss_db_exception.OssDBInitPartError)
|
63
|
+
# def init_part(self, key) -> models.InitMultipartUploadResult:
|
64
|
+
# """初始化分片上传"""
|
65
|
+
# return self._client.init_multipart_upload(key)
|
66
|
+
#
|
67
|
+
# @decorator_oss_db(exception=oss_db_exception.OssDBPutObjError)
|
68
|
+
# def put(self, key, data) -> models.PutObjectResult:
|
69
|
+
# """文件上传"""
|
70
|
+
# return self._client.put_object(key, data)
|
71
|
+
#
|
72
|
+
# @decorator_oss_db(exception=oss_db_exception.OssDBPutPartError)
|
73
|
+
# def put_part(self, key, upload_id, position, data) -> models.PutObjectResult:
|
74
|
+
# """分片上传"""
|
75
|
+
# return self._client.upload_part(key, upload_id, position, data)
|
76
|
+
#
|
77
|
+
# def list_part(self, key, upload_id): # -> List[models.ListPartsResult]:
|
78
|
+
# """获取分片列表"""
|
79
|
+
# return [part_info for part_info in PartIterator(self._client, key, upload_id)]
|
80
|
+
#
|
81
|
+
# @decorator_oss_db(exception=oss_db_exception.OssDBMergeError)
|
82
|
+
# def merge(self, key, upload_id, parts=None) -> models.PutObjectResult:
|
83
|
+
# """合并分片"""
|
84
|
+
# headers = None if parts else {"x-oss-complete-all": "yes"}
|
85
|
+
# return self._client.complete_multipart_upload(key, upload_id, parts, headers=headers)
|
86
|
+
#
|
87
|
+
# @decorator_oss_db(exception=oss_db_exception.OssDBAppendObjError)
|
88
|
+
# def append(self, key, position, data) -> models.AppendObjectResult:
|
89
|
+
# """追加上传"""
|
90
|
+
# return self._client.append_object(key, position, data)
|
91
|
+
#
|
92
|
+
# def iter_data(self, data, chunk_size=None):
|
93
|
+
# chunk_size = chunk_size or self.chunk_size
|
94
|
+
# if isinstance(data, Response):
|
95
|
+
# for part_data in data.iter_content(chunk_size):
|
96
|
+
# yield part_data
|
97
|
+
# if isinstance(data, bytes):
|
98
|
+
# for i in range(0, len(data), chunk_size):
|
99
|
+
# yield data[i:i + chunk_size]
|
100
|
+
#
|
101
|
+
# def assemble(self, ready_data, data, chunk_size=None):
|
102
|
+
# upload_data = b""
|
103
|
+
# ready_data = ready_data + data
|
104
|
+
# chunk_size = chunk_size or self.chunk_size
|
105
|
+
# if len(ready_data) >= chunk_size:
|
106
|
+
# upload_data = ready_data[:chunk_size]
|
107
|
+
# ready_data = ready_data[chunk_size:]
|
108
|
+
# return ready_data, upload_data
|
109
|
+
#
|
110
|
+
# def content_length(self, key: str) -> int:
|
111
|
+
# head = self.head(key)
|
112
|
+
# return head.content_length
|
113
|
+
#
|
@@ -1,113 +0,0 @@
|
|
1
|
-
|
2
|
-
from cobweb import setting
|
3
|
-
from requests import Response
|
4
|
-
from oss2 import Auth, Bucket, models, PartIterator
|
5
|
-
from cobweb.exceptions import oss_db_exception
|
6
|
-
from cobweb.utils.decorators import decorator_oss_db
|
7
|
-
|
8
|
-
|
9
|
-
class OssUtil:
|
10
|
-
|
11
|
-
def __init__(
|
12
|
-
self,
|
13
|
-
bucket=None,
|
14
|
-
endpoint=None,
|
15
|
-
access_key=None,
|
16
|
-
secret_key=None,
|
17
|
-
chunk_size=None,
|
18
|
-
min_upload_size=None,
|
19
|
-
**kwargs
|
20
|
-
):
|
21
|
-
self.bucket = bucket or setting.OSS_BUCKET
|
22
|
-
self.endpoint = endpoint or setting.OSS_ENDPOINT
|
23
|
-
self.chunk_size = int(chunk_size or setting.OSS_CHUNK_SIZE)
|
24
|
-
self.min_upload_size = int(min_upload_size or setting.OSS_MIN_UPLOAD_SIZE)
|
25
|
-
|
26
|
-
self.failed_count = 0
|
27
|
-
self._kw = kwargs
|
28
|
-
|
29
|
-
self._auth = Auth(
|
30
|
-
access_key_id=access_key or setting.OSS_ACCESS_KEY,
|
31
|
-
access_key_secret=secret_key or setting.OSS_SECRET_KEY
|
32
|
-
)
|
33
|
-
self._client = Bucket(
|
34
|
-
auth=self._auth,
|
35
|
-
endpoint=self.endpoint,
|
36
|
-
bucket_name=self.bucket,
|
37
|
-
**self._kw
|
38
|
-
)
|
39
|
-
|
40
|
-
def failed(self):
|
41
|
-
self.failed_count += 1
|
42
|
-
if self.failed_count >= 5:
|
43
|
-
self._client = Bucket(
|
44
|
-
auth=self._auth,
|
45
|
-
endpoint=self.endpoint,
|
46
|
-
bucket_name=self.bucket,
|
47
|
-
**self._kw
|
48
|
-
)
|
49
|
-
|
50
|
-
def exists(self, key: str) -> bool:
|
51
|
-
try:
|
52
|
-
result = self._client.object_exists(key)
|
53
|
-
self.failed_count = 0
|
54
|
-
return result
|
55
|
-
except Exception as e:
|
56
|
-
self.failed()
|
57
|
-
raise e
|
58
|
-
|
59
|
-
def head(self, key: str) -> models.HeadObjectResult:
|
60
|
-
return self._client.head_object(key)
|
61
|
-
|
62
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBInitPartError)
|
63
|
-
def init_part(self, key) -> models.InitMultipartUploadResult:
|
64
|
-
"""初始化分片上传"""
|
65
|
-
return self._client.init_multipart_upload(key)
|
66
|
-
|
67
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBPutObjError)
|
68
|
-
def put(self, key, data) -> models.PutObjectResult:
|
69
|
-
"""文件上传"""
|
70
|
-
return self._client.put_object(key, data)
|
71
|
-
|
72
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBPutPartError)
|
73
|
-
def put_part(self, key, upload_id, position, data) -> models.PutObjectResult:
|
74
|
-
"""分片上传"""
|
75
|
-
return self._client.upload_part(key, upload_id, position, data)
|
76
|
-
|
77
|
-
def list_part(self, key, upload_id): # -> List[models.ListPartsResult]:
|
78
|
-
"""获取分片列表"""
|
79
|
-
return [part_info for part_info in PartIterator(self._client, key, upload_id)]
|
80
|
-
|
81
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBMergeError)
|
82
|
-
def merge(self, key, upload_id, parts=None) -> models.PutObjectResult:
|
83
|
-
"""合并分片"""
|
84
|
-
headers = None if parts else {"x-oss-complete-all": "yes"}
|
85
|
-
return self._client.complete_multipart_upload(key, upload_id, parts, headers=headers)
|
86
|
-
|
87
|
-
@decorator_oss_db(exception=oss_db_exception.OssDBAppendObjError)
|
88
|
-
def append(self, key, position, data) -> models.AppendObjectResult:
|
89
|
-
"""追加上传"""
|
90
|
-
return self._client.append_object(key, position, data)
|
91
|
-
|
92
|
-
def iter_data(self, data, chunk_size=None):
|
93
|
-
chunk_size = chunk_size or self.chunk_size
|
94
|
-
if isinstance(data, Response):
|
95
|
-
for part_data in data.iter_content(chunk_size):
|
96
|
-
yield part_data
|
97
|
-
if isinstance(data, bytes):
|
98
|
-
for i in range(0, len(data), chunk_size):
|
99
|
-
yield data[i:i + chunk_size]
|
100
|
-
|
101
|
-
def assemble(self, ready_data, data, chunk_size=None):
|
102
|
-
upload_data = b""
|
103
|
-
ready_data = ready_data + data
|
104
|
-
chunk_size = chunk_size or self.chunk_size
|
105
|
-
if len(ready_data) >= chunk_size:
|
106
|
-
upload_data = ready_data[:chunk_size]
|
107
|
-
ready_data = ready_data[chunk_size:]
|
108
|
-
return ready_data, upload_data
|
109
|
-
|
110
|
-
def content_length(self, key: str) -> int:
|
111
|
-
head = self.head(key)
|
112
|
-
return head.content_length
|
113
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cobweb-launcher-3.1.8 → cobweb-launcher-3.1.10}/cobweb_launcher.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|