redis-allocator 0.3.2__py3-none-any.whl → 0.3.3__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.
@@ -1 +1 @@
1
- __version__ = '0.3.2'
1
+ __version__ = '0.3.3'
@@ -97,7 +97,7 @@ class RedisAllocatableClass(ABC):
97
97
 
98
98
  def open(self):
99
99
  """Open the object."""
100
- pass
100
+ return self
101
101
 
102
102
  def close(self):
103
103
  """close the object."""
@@ -162,6 +162,7 @@ class RedisAllocatorObject(Generic[U]):
162
162
  """Open the object."""
163
163
  if self.obj is not None:
164
164
  self.obj.open()
165
+ return self
165
166
 
166
167
  def close(self):
167
168
  """Kill the object."""
@@ -282,9 +283,11 @@ class RedisAllocatorPolicy(ABC):
282
283
 
283
284
  def check_health_once(self, r_obj: RedisAllocatorObject, duration: int = 3600) -> bool:
284
285
  """Check the health of the object."""
285
- with contextlib.closing(r_obj):
286
+ with contextlib.closing(r_obj.open()):
286
287
  try:
287
288
  if r_obj.is_healthy():
289
+ if r_obj.allocator.shared:
290
+ r_obj.allocator.unlock(r_obj.key) # set the key as free
288
291
  return True
289
292
  else:
290
293
  r_obj.set_unhealthy(duration)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: redis-allocator
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Redis-based resource allocation system.
5
5
  Home-page: https://github.com/invoker-bot/RedisAllocator-python
6
6
  Author: Invoker Bot
@@ -1,15 +1,15 @@
1
1
  redis_allocator/__init__.py,sha256=TVjUm-8YEu_MQD_PkfeIKiVknpCJBrUY9cWN1LlaZcU,1016
2
- redis_allocator/_version.py,sha256=bqu4G7Is-8Were-hMi-SthEalL7QW-PAbKWGZ9pVB6U,22
3
- redis_allocator/allocator.py,sha256=Q0oDhUyjlpk6WoibvmlFS0pEmxk3qwLUHB277P3EMrE,47120
2
+ redis_allocator/_version.py,sha256=on4Bj4mGEjEjyUkQExxprhOoEopcv_sPapsEnNxyelE,22
3
+ redis_allocator/allocator.py,sha256=oFJSRAhFJsBbeho5TibY81_3Vy07glrAuEhpIOYfeJI,47282
4
4
  redis_allocator/lock.py,sha256=fqf6WUWHKYenEArWopMIF6kWEnDfADC-bZvnQImsQVo,27400
5
5
  redis_allocator/task_queue.py,sha256=8DjNr2uxhzCsHatV_CHOeGh7_K9pqQZFApSbe2blRO0,14989
6
- redis_allocator-0.3.2.dist-info/licenses/LICENSE,sha256=Wt4X1rHpffQfEiyWcDUx8BMLjXxfPqaiYZ7Lgsj7L4c,1068
6
+ redis_allocator-0.3.3.dist-info/licenses/LICENSE,sha256=Wt4X1rHpffQfEiyWcDUx8BMLjXxfPqaiYZ7Lgsj7L4c,1068
7
7
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- tests/conftest.py,sha256=1QA3fxdX2XmVDEXY9L9D6NAWlAxlyifK8W9rnO24ig8,3947
8
+ tests/conftest.py,sha256=Ts82uylQSzP_GcaN0E02o3xcFdjw20cXNzh3RAdYKW4,3967
9
9
  tests/test_allocator.py,sha256=hFKgLe_yONtEjjm6zssUnhK0tzihG_1xZMziztHmqqA,22404
10
10
  tests/test_lock.py,sha256=MDMRNN46VhWqkHUIhYOMEDgZkFFCW_WjwRLTOjkFF-Q,46952
11
11
  tests/test_task_queue.py,sha256=Fh5naikFajfOvL6GngEy_TPfOYCYZolZfVwtR6T4dTY,31710
12
- redis_allocator-0.3.2.dist-info/METADATA,sha256=H_C0Um1MegEzuo6A_UhgWkIN0SsQA_CScHhfwqatfw0,21653
13
- redis_allocator-0.3.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
14
- redis_allocator-0.3.2.dist-info/top_level.txt,sha256=0hXzU7sK5FCeSolTEYxThOt3HOybnwaXv1FLRJvHVgI,22
15
- redis_allocator-0.3.2.dist-info/RECORD,,
12
+ redis_allocator-0.3.3.dist-info/METADATA,sha256=oEPcsqP1oiKP_HaZgIgfEEqIxuY6c9aoapC5ecLrP8w,21653
13
+ redis_allocator-0.3.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
14
+ redis_allocator-0.3.3.dist-info/top_level.txt,sha256=0hXzU7sK5FCeSolTEYxThOt3HOybnwaXv1FLRJvHVgI,22
15
+ redis_allocator-0.3.3.dist-info/RECORD,,
tests/conftest.py CHANGED
@@ -66,6 +66,7 @@ class _TestObject(RedisAllocatableClass):
66
66
  def open(self):
67
67
  """Open the object."""
68
68
  self.closed = False
69
+ return self
69
70
 
70
71
  def close(self):
71
72
  """Mark the object as closed."""