pybiolib 1.1.1003__py3-none-any.whl → 1.1.1011__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.
- biolib/utils/cache_state.py +25 -22
- {pybiolib-1.1.1003.dist-info → pybiolib-1.1.1011.dist-info}/METADATA +1 -1
- {pybiolib-1.1.1003.dist-info → pybiolib-1.1.1011.dist-info}/RECORD +6 -6
- {pybiolib-1.1.1003.dist-info → pybiolib-1.1.1011.dist-info}/LICENSE +0 -0
- {pybiolib-1.1.1003.dist-info → pybiolib-1.1.1011.dist-info}/WHEEL +0 -0
- {pybiolib-1.1.1003.dist-info → pybiolib-1.1.1011.dist-info}/entry_points.txt +0 -0
biolib/utils/cache_state.py
CHANGED
@@ -42,19 +42,22 @@ class CacheState(abc.ABC, Generic[StateType]):
|
|
42
42
|
|
43
43
|
def __enter__(self) -> StateType:
|
44
44
|
logger_no_user_data.debug(f'CacheState: Entering state path: {self._state_path}...')
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
self.
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
45
|
+
try:
|
46
|
+
self._acquire_state_lock()
|
47
|
+
if os.path.exists(self._state_path):
|
48
|
+
with open(self._state_path, mode='r') as file:
|
49
|
+
self._state = json.loads(file.read())
|
50
|
+
else:
|
51
|
+
self._state = self._get_default_state()
|
52
|
+
with open(self._state_path, mode='w') as file:
|
53
|
+
file.write(json.dumps(self._state))
|
54
|
+
|
55
|
+
# Check for type checking
|
56
|
+
if self._state is None:
|
57
|
+
raise CacheStateError('Internal state is not defined')
|
58
|
+
except BaseException as error: # pylint: disable=broad-except
|
59
|
+
logger_no_user_data.debug(f'Could not get LFS lock, got error: {error}...')
|
60
|
+
raise error
|
58
61
|
return self._state
|
59
62
|
|
60
63
|
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
@@ -65,17 +68,17 @@ class CacheState(abc.ABC, Generic[StateType]):
|
|
65
68
|
logger_no_user_data.debug(f'CacheState: Exited state path: {self._state_path}')
|
66
69
|
|
67
70
|
def _acquire_state_lock(self) -> None:
|
68
|
-
|
69
|
-
|
71
|
+
for _ in range(10):
|
72
|
+
try:
|
73
|
+
lock_file = open(self._state_lock_path, mode='x')
|
74
|
+
lock_file.close()
|
75
|
+
return
|
76
|
+
except BaseException as error: # pylint: disable=broad-except
|
77
|
+
logger_no_user_data.debug(f'Failed to acquire lock file "{self._state_lock_path}". Got error: {error}')
|
70
78
|
|
71
|
-
|
72
|
-
time.sleep(seconds_to_sleep)
|
73
|
-
timeout_seconds -= seconds_to_sleep
|
74
|
-
if timeout_seconds < 0:
|
75
|
-
raise CacheStateError('Cache state timed out waiting for lock file')
|
79
|
+
time.sleep(0.5)
|
76
80
|
|
77
|
-
|
78
|
-
lock_file.close()
|
81
|
+
raise CacheStateError(f'Cache state timed out waiting to acquire lock file "{self._state_lock_path}"')
|
79
82
|
|
80
83
|
def _release_state_lock(self) -> None:
|
81
84
|
if os.path.exists(self._state_lock_path):
|
@@ -98,7 +98,7 @@ biolib/typing_utils.py,sha256=krMhxB3SedVQA3HXIrC7DBXWpHKWN5JNmXGcSrrysOc,263
|
|
98
98
|
biolib/user/__init__.py,sha256=Db5wtxLfFz3ID9TULSSTo77csw9tO6RtxMRvV5cqKEE,39
|
99
99
|
biolib/user/sign_in.py,sha256=CvHBgoYjg5d5CL9etVopns_g1pImgW8mQH3zAjpe1Ik,2061
|
100
100
|
biolib/utils/__init__.py,sha256=a_7oy3XCxrVDdsCynxjw27tOgOongkOh0bw8cp6TXWo,8219
|
101
|
-
biolib/utils/cache_state.py,sha256=
|
101
|
+
biolib/utils/cache_state.py,sha256=BFrZlV4XZIueIFzAFiPidX4hmwADKY5Y5ZuqlerF5l0,3060
|
102
102
|
biolib/utils/multipart_uploader.py,sha256=XFEz-4LRNVFNR6D_FKCecjxosY0bgaR5DGigKAyY5iI,9717
|
103
103
|
biolib/utils/seq_util.py,sha256=CEFtNVBcnmVq_801T_jT4g1O30_iI4P-sRZ2GCU9EqU,1757
|
104
104
|
biolib/utils/zip/remote_zip.py,sha256=NCdUnVbGCv7SfXCI-yVU-is_OnyWmLAnVpIdSvo-W4k,23500
|
@@ -107,8 +107,8 @@ biolib/validators/validate_argument.py,sha256=B-tqgMgXuTvJLhaMWcBTUKw18L5brJtIdf
|
|
107
107
|
biolib/validators/validate_module.py,sha256=aHe0YAWFSrMbZNw-h64oweqruDS-k7KOUzK1ECpG8Wg,13298
|
108
108
|
biolib/validators/validate_zip_file.py,sha256=2j8kJ1WF2u5OyMkfEDCoU_BvOtr8gLPWTtsmUG0zQ5g,1655
|
109
109
|
biolib/validators/validator_utils.py,sha256=2QCJWdKiLTUHsvjDidrXKBjH95kKsEmFwd17muTGL0M,2135
|
110
|
-
pybiolib-1.1.
|
111
|
-
pybiolib-1.1.
|
112
|
-
pybiolib-1.1.
|
113
|
-
pybiolib-1.1.
|
114
|
-
pybiolib-1.1.
|
110
|
+
pybiolib-1.1.1011.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
|
111
|
+
pybiolib-1.1.1011.dist-info/METADATA,sha256=oJS8zh0ywTWDD79FbnPQjbYPy_GXh2XcqWnyUUhEVtY,1612
|
112
|
+
pybiolib-1.1.1011.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
113
|
+
pybiolib-1.1.1011.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
|
114
|
+
pybiolib-1.1.1011.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|