cobweb-launcher 1.2.60__py3-none-any.whl → 1.2.61__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.
cobweb/utils/oss.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import List
1
+
2
2
  from cobweb import setting
3
3
  from requests import Response
4
4
  from oss2 import Auth, Bucket, models, PartIterator
@@ -23,6 +23,9 @@ class OssUtil:
23
23
  self.chunk_size = int(chunk_size or setting.OSS_CHUNK_SIZE)
24
24
  self.min_upload_size = int(min_upload_size or setting.OSS_MIN_UPLOAD_SIZE)
25
25
 
26
+ self.failed_count = 0
27
+ self._kw = kwargs
28
+
26
29
  self._auth = Auth(
27
30
  access_key_id=access_key or setting.OSS_ACCESS_KEY,
28
31
  access_key_secret=secret_key or setting.OSS_SECRET_KEY
@@ -31,11 +34,27 @@ class OssUtil:
31
34
  auth=self._auth,
32
35
  endpoint=self.endpoint,
33
36
  bucket_name=self.bucket,
34
- **kwargs
37
+ **self._kw
35
38
  )
36
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
+
37
50
  def exists(self, key: str) -> bool:
38
- return self._client.object_exists(key)
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
39
58
 
40
59
  def head(self, key: str) -> models.HeadObjectResult:
41
60
  return self._client.head_object(key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cobweb-launcher
3
- Version: 1.2.60
3
+ Version: 1.2.61
4
4
  Summary: spider_hole
5
5
  Home-page: https://github.com/Juannie-PP/cobweb
6
6
  Author: Juannie-PP
@@ -36,10 +36,10 @@ cobweb/schedulers/scheduler_redis.py,sha256=E5fjc3nNld8GbUhUGT7uY4smRejj2J2ZIzp2
36
36
  cobweb/utils/__init__.py,sha256=Ev2LZZ1-S56iQYDqFZrqadizEv4Gk8Of-DraH-_WnKY,109
37
37
  cobweb/utils/bloom.py,sha256=vng-YbKgh9HbtpAWYf_nkUSbfVTOj40aqUUejRYlsCU,1752
38
38
  cobweb/utils/dotting.py,sha256=mVICaa26R-dQ4JGmPK-kkR6QjX38QiRewXZnGb2DCIc,1784
39
- cobweb/utils/oss.py,sha256=gyt8-UB07tVphZLQXMOf-JTJwU-mWq8KZkOXKkAf3uk,3513
39
+ cobweb/utils/oss.py,sha256=6x_ugXanh1R-6ZylQzUDQh4OeFZHujhWFCOxbzy53JY,3984
40
40
  cobweb/utils/tools.py,sha256=5JEaaAwYoV9Sdla2UBIJn6faUBuXmxUMagm9ck6FVqs,1253
41
- cobweb_launcher-1.2.60.dist-info/LICENSE,sha256=z1rxSIGOyzcSb3orZxFPxzx-0C1vTocmswqBNxpKfEk,1063
42
- cobweb_launcher-1.2.60.dist-info/METADATA,sha256=9RTAhglArwI9C7Vr_oIxpE-2i7V3gg15RucZJ3r58n4,6510
43
- cobweb_launcher-1.2.60.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
44
- cobweb_launcher-1.2.60.dist-info/top_level.txt,sha256=4GETBGNsKqiCUezmT-mJn7tjhcDlu7nLIV5gGgHBW4I,7
45
- cobweb_launcher-1.2.60.dist-info/RECORD,,
41
+ cobweb_launcher-1.2.61.dist-info/LICENSE,sha256=z1rxSIGOyzcSb3orZxFPxzx-0C1vTocmswqBNxpKfEk,1063
42
+ cobweb_launcher-1.2.61.dist-info/METADATA,sha256=vtAEmhDSAlOHdtb9XfsPaMGCtXk4z-zXao5IifOxBhY,6510
43
+ cobweb_launcher-1.2.61.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
44
+ cobweb_launcher-1.2.61.dist-info/top_level.txt,sha256=4GETBGNsKqiCUezmT-mJn7tjhcDlu7nLIV5gGgHBW4I,7
45
+ cobweb_launcher-1.2.61.dist-info/RECORD,,