database-wrapper-redis 0.2.32__tar.gz → 0.2.36__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.
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/PKG-INFO +3 -3
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis/connector.py +30 -9
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis.egg-info/PKG-INFO +3 -3
- database_wrapper_redis-0.2.36/database_wrapper_redis.egg-info/requires.txt +2 -0
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/pyproject.toml +2 -2
- database_wrapper_redis-0.2.32/database_wrapper_redis.egg-info/requires.txt +0 -2
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/README.md +0 -0
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis/__init__.py +0 -0
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis/py.typed +0 -0
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis.egg-info/SOURCES.txt +0 -0
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis.egg-info/dependency_links.txt +0 -0
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis.egg-info/top_level.txt +0 -0
- {database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper_redis
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.36
|
|
4
4
|
Summary: database_wrapper for Redis database
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
6
|
License: GNU General Public License v3.0 (GPL-3.0)
|
|
@@ -32,8 +32,8 @@ Classifier: Topic :: Software Development
|
|
|
32
32
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
33
|
Requires-Python: >=3.8
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
|
-
Requires-Dist: database_wrapper==0.2.
|
|
36
|
-
Requires-Dist: redis
|
|
35
|
+
Requires-Dist: database_wrapper==0.2.36
|
|
36
|
+
Requires-Dist: redis>=8.0
|
|
37
37
|
|
|
38
38
|
# database_wrapper_redis
|
|
39
39
|
|
{database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis/connector.py
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
import logging
|
|
2
3
|
from contextvars import ContextVar
|
|
3
4
|
from threading import Event
|
|
@@ -267,12 +268,24 @@ class RedisDb(KVDbBase):
|
|
|
267
268
|
self.logger.error(f"{logBuffer}ERR ({e})")
|
|
268
269
|
self.shutdown_requested.wait(self.timeout)
|
|
269
270
|
tries += 1
|
|
270
|
-
if tries >
|
|
271
|
+
if tries > self.config["instant_retries"]:
|
|
271
272
|
raise
|
|
272
273
|
continue
|
|
273
274
|
|
|
274
275
|
raise Exception("Cancelled connection creation")
|
|
275
276
|
|
|
277
|
+
def close(self) -> None:
|
|
278
|
+
"""
|
|
279
|
+
Close connection to the database.
|
|
280
|
+
"""
|
|
281
|
+
try:
|
|
282
|
+
if self._connection:
|
|
283
|
+
self._connection.close()
|
|
284
|
+
except Exception as e:
|
|
285
|
+
self.logger.debug(f"Error while closing connection: {e}")
|
|
286
|
+
finally:
|
|
287
|
+
self._connection = None
|
|
288
|
+
|
|
276
289
|
|
|
277
290
|
class RedisDbAsync(KVDbBase):
|
|
278
291
|
context_connection: ContextVar[RedisClientAsync | None]
|
|
@@ -297,7 +310,8 @@ class RedisDbAsync(KVDbBase):
|
|
|
297
310
|
self.logger.debug("Dealloc")
|
|
298
311
|
|
|
299
312
|
# Just to be sure as async does not have __del__
|
|
300
|
-
|
|
313
|
+
if hasattr(self, "_connection"):
|
|
314
|
+
del self._connection
|
|
301
315
|
|
|
302
316
|
async def new_connection(self) -> RedisClientAsync:
|
|
303
317
|
tries = 0
|
|
@@ -330,9 +344,11 @@ class RedisDbAsync(KVDbBase):
|
|
|
330
344
|
await redis_conn.close()
|
|
331
345
|
|
|
332
346
|
self.logger.error(f"ERR ({e})", extra={"clean": True})
|
|
333
|
-
|
|
347
|
+
# Event.wait() would block the whole event loop; the loop condition
|
|
348
|
+
# re-checks shutdown_requested after the sleep
|
|
349
|
+
await asyncio.sleep(self.timeout)
|
|
334
350
|
tries += 1
|
|
335
|
-
if tries >
|
|
351
|
+
if tries > self.config["instant_retries"]:
|
|
336
352
|
raise
|
|
337
353
|
continue
|
|
338
354
|
|
|
@@ -411,7 +427,7 @@ class RedisDbWithPool(KVDbBase):
|
|
|
411
427
|
self.logger.error(f"{logBuffer}ERR ({e})")
|
|
412
428
|
self.shutdown_requested.wait(self.timeout)
|
|
413
429
|
tries += 1
|
|
414
|
-
if tries >
|
|
430
|
+
if tries > self.config["instant_retries"]:
|
|
415
431
|
raise
|
|
416
432
|
continue
|
|
417
433
|
|
|
@@ -468,8 +484,11 @@ class RedisDbWithPoolAsync(KVDbBase):
|
|
|
468
484
|
self.logger.debug("Dealloc")
|
|
469
485
|
|
|
470
486
|
# Just to be sure as async does not have __del__
|
|
471
|
-
|
|
472
|
-
|
|
487
|
+
if hasattr(self, "_connection"):
|
|
488
|
+
del self._connection
|
|
489
|
+
|
|
490
|
+
if hasattr(self, "pool"):
|
|
491
|
+
del self.pool
|
|
473
492
|
|
|
474
493
|
async def new_connection(self) -> RedisClientAsync:
|
|
475
494
|
tries = 0
|
|
@@ -487,9 +506,11 @@ class RedisDbWithPoolAsync(KVDbBase):
|
|
|
487
506
|
await redis_conn.close()
|
|
488
507
|
|
|
489
508
|
self.logger.error(f"ERR ({e})", extra={"clean": True})
|
|
490
|
-
|
|
509
|
+
# Event.wait() would block the whole event loop; the loop condition
|
|
510
|
+
# re-checks shutdown_requested after the sleep
|
|
511
|
+
await asyncio.sleep(self.timeout)
|
|
491
512
|
tries += 1
|
|
492
|
-
if tries >
|
|
513
|
+
if tries > self.config["instant_retries"]:
|
|
493
514
|
raise
|
|
494
515
|
continue
|
|
495
516
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper_redis
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.36
|
|
4
4
|
Summary: database_wrapper for Redis database
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
6
|
License: GNU General Public License v3.0 (GPL-3.0)
|
|
@@ -32,8 +32,8 @@ Classifier: Topic :: Software Development
|
|
|
32
32
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
33
|
Requires-Python: >=3.8
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
|
-
Requires-Dist: database_wrapper==0.2.
|
|
36
|
-
Requires-Dist: redis
|
|
35
|
+
Requires-Dist: database_wrapper==0.2.36
|
|
36
|
+
Requires-Dist: redis>=8.0
|
|
37
37
|
|
|
38
38
|
# database_wrapper_redis
|
|
39
39
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "database_wrapper_redis"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.36"
|
|
8
8
|
description = "database_wrapper for Redis database"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -32,7 +32,7 @@ classifiers = [
|
|
|
32
32
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
33
33
|
]
|
|
34
34
|
keywords = ["database", "wrapper", "python", "redis"]
|
|
35
|
-
dependencies = ["database_wrapper == 0.2.
|
|
35
|
+
dependencies = ["database_wrapper == 0.2.36", "redis >= 8.0"]
|
|
36
36
|
|
|
37
37
|
[project.urls]
|
|
38
38
|
Homepage = "https://github.com/gintsmurans/py_database_wrapper"
|
|
File without changes
|
{database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis/__init__.py
RENAMED
|
File without changes
|
{database_wrapper_redis-0.2.32 → database_wrapper_redis-0.2.36}/database_wrapper_redis/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|