python-pq 0.1.7__tar.gz → 0.2.0__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.
- {python_pq-0.1.7 → python_pq-0.2.0}/PKG-INFO +1 -1
- {python_pq-0.1.7 → python_pq-0.2.0}/pyproject.toml +1 -1
- {python_pq-0.1.7 → python_pq-0.2.0}/src/pq/client.py +23 -1
- {python_pq-0.1.7 → python_pq-0.2.0}/README.md +0 -0
- {python_pq-0.1.7 → python_pq-0.2.0}/src/pq/__init__.py +0 -0
- {python_pq-0.1.7 → python_pq-0.2.0}/src/pq/config.py +0 -0
- {python_pq-0.1.7 → python_pq-0.2.0}/src/pq/logging.py +0 -0
- {python_pq-0.1.7 → python_pq-0.2.0}/src/pq/models.py +0 -0
- {python_pq-0.1.7 → python_pq-0.2.0}/src/pq/priority.py +0 -0
- {python_pq-0.1.7 → python_pq-0.2.0}/src/pq/registry.py +0 -0
- {python_pq-0.1.7 → python_pq-0.2.0}/src/pq/serialization.py +0 -0
- {python_pq-0.1.7 → python_pq-0.2.0}/src/pq/worker.py +0 -0
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
from collections.abc import Callable, Set
|
|
4
4
|
from contextlib import contextmanager
|
|
5
5
|
from datetime import UTC, datetime, timedelta
|
|
6
|
-
from
|
|
6
|
+
from types import TracebackType
|
|
7
|
+
from typing import Any, Self
|
|
7
8
|
|
|
8
9
|
from croniter import croniter
|
|
9
10
|
from croniter.croniter import CroniterBadCronError
|
|
@@ -43,6 +44,27 @@ class PQ:
|
|
|
43
44
|
finally:
|
|
44
45
|
session.close()
|
|
45
46
|
|
|
47
|
+
def close(self) -> None:
|
|
48
|
+
"""Close all database connections and dispose the engine.
|
|
49
|
+
|
|
50
|
+
This closes all connections in the connection pool. After calling
|
|
51
|
+
this method, the PQ instance should not be used.
|
|
52
|
+
"""
|
|
53
|
+
self._engine.dispose()
|
|
54
|
+
|
|
55
|
+
def __enter__(self) -> Self:
|
|
56
|
+
"""Enter context manager."""
|
|
57
|
+
return self
|
|
58
|
+
|
|
59
|
+
def __exit__(
|
|
60
|
+
self,
|
|
61
|
+
exc_type: type[BaseException] | None,
|
|
62
|
+
exc_val: BaseException | None,
|
|
63
|
+
exc_tb: TracebackType | None,
|
|
64
|
+
) -> None:
|
|
65
|
+
"""Exit context manager and close connections."""
|
|
66
|
+
self.close()
|
|
67
|
+
|
|
46
68
|
def create_tables(self) -> None:
|
|
47
69
|
"""Create all tables (for testing)."""
|
|
48
70
|
Base.metadata.create_all(self._engine)
|
|
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
|