ddutils 0.3.2__tar.gz → 0.3.3__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.
- {ddutils-0.3.2 → ddutils-0.3.3}/PKG-INFO +16 -1
- {ddutils-0.3.2 → ddutils-0.3.3}/README.md +15 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/__init__.py +2 -0
- ddutils-0.3.3/ddutils/context_helpers.py +23 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/pyproject.toml +1 -1
- {ddutils-0.3.2 → ddutils-0.3.3}/pyproject.toml.orig +1 -1
- {ddutils-0.3.2 → ddutils-0.3.3}/LICENSE +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/annotation_helpers.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/class_helpers.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/connections.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/convertors.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/datetime_helpers.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/feature_flags.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/function_exceptions_extractor.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/function_helpers.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/module_getter.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/object_getter.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/py.typed +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/safe_decorators.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/scoped_registry.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/sequence_helpers.py +0 -0
- {ddutils-0.3.2 → ddutils-0.3.3}/ddutils/value_helpers.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ddutils
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Domain Driven Utils Library
|
|
5
5
|
Keywords: python,ddutils
|
|
6
6
|
Author: davyddd
|
|
@@ -610,6 +610,21 @@ construction; a storage builds it with `from_dict` and, when what it read is not
|
|
|
610
610
|
it as the defaults. A storage failure raises `FeatureFlagStorageError`
|
|
611
611
|
with the cause chained.
|
|
612
612
|
|
|
613
|
+
## Context Helpers
|
|
614
|
+
|
|
615
|
+
### async_suppress
|
|
616
|
+
|
|
617
|
+
`contextlib.suppress` as an async context manager, so it can share one `async with` with other async context
|
|
618
|
+
managers instead of nesting a sync `with` inside. Swallows only the listed exceptions raised inside the block.
|
|
619
|
+
|
|
620
|
+
```python
|
|
621
|
+
from ddredis.lock import AlreadyAcquiredError, RedisLock
|
|
622
|
+
from ddutils.context_helpers import async_suppress
|
|
623
|
+
|
|
624
|
+
async with async_suppress(AlreadyAcquiredError), RedisLock(redis_client_factory, 'sync-profiles', timeout=30):
|
|
625
|
+
await sync_profiles() # skipped when another worker holds the lock
|
|
626
|
+
```
|
|
627
|
+
|
|
613
628
|
## Function Exception Extraction
|
|
614
629
|
|
|
615
630
|
AST-based introspection for extracting exceptions from function source code.
|
|
@@ -592,6 +592,21 @@ construction; a storage builds it with `from_dict` and, when what it read is not
|
|
|
592
592
|
it as the defaults. A storage failure raises `FeatureFlagStorageError`
|
|
593
593
|
with the cause chained.
|
|
594
594
|
|
|
595
|
+
## Context Helpers
|
|
596
|
+
|
|
597
|
+
### async_suppress
|
|
598
|
+
|
|
599
|
+
`contextlib.suppress` as an async context manager, so it can share one `async with` with other async context
|
|
600
|
+
managers instead of nesting a sync `with` inside. Swallows only the listed exceptions raised inside the block.
|
|
601
|
+
|
|
602
|
+
```python
|
|
603
|
+
from ddredis.lock import AlreadyAcquiredError, RedisLock
|
|
604
|
+
from ddutils.context_helpers import async_suppress
|
|
605
|
+
|
|
606
|
+
async with async_suppress(AlreadyAcquiredError), RedisLock(redis_client_factory, 'sync-profiles', timeout=30):
|
|
607
|
+
await sync_profiles() # skipped when another worker holds the lock
|
|
608
|
+
```
|
|
609
|
+
|
|
595
610
|
## Function Exception Extraction
|
|
596
611
|
|
|
597
612
|
AST-based introspection for extracting exceptions from function source code.
|
|
@@ -2,6 +2,7 @@ from . import (
|
|
|
2
2
|
annotation_helpers,
|
|
3
3
|
class_helpers,
|
|
4
4
|
connections,
|
|
5
|
+
context_helpers,
|
|
5
6
|
convertors,
|
|
6
7
|
datetime_helpers,
|
|
7
8
|
feature_flags,
|
|
@@ -19,6 +20,7 @@ __all__ = (
|
|
|
19
20
|
'annotation_helpers',
|
|
20
21
|
'class_helpers',
|
|
21
22
|
'connections',
|
|
23
|
+
'context_helpers',
|
|
22
24
|
'convertors',
|
|
23
25
|
'datetime_helpers',
|
|
24
26
|
'feature_flags',
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from collections.abc import AsyncIterator
|
|
2
|
+
from contextlib import asynccontextmanager
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@asynccontextmanager
|
|
6
|
+
async def async_suppress(*exceptions: type[BaseException]) -> AsyncIterator[None]:
|
|
7
|
+
"""
|
|
8
|
+
`contextlib.suppress` as an async context manager, so it can share one `async with` with other async
|
|
9
|
+
context managers instead of nesting a sync `with` inside:
|
|
10
|
+
|
|
11
|
+
async with async_suppress(AlreadyAcquiredError), RedisLock(redis_client_factory, 'sync', timeout=30):
|
|
12
|
+
await sync_profiles()
|
|
13
|
+
|
|
14
|
+
Like `suppress`, it swallows only the listed exceptions raised inside the block; the block is left at the
|
|
15
|
+
point of the exception.
|
|
16
|
+
"""
|
|
17
|
+
try: # noqa: SIM105 # suppress() is exactly what this wraps into an async context manager
|
|
18
|
+
yield
|
|
19
|
+
except exceptions:
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
__all__ = ('async_suppress',)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|