python-cq 0.7.3__tar.gz → 0.7.4__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_cq-0.7.3 → python_cq-0.7.4}/PKG-INFO +1 -1
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/message.py +6 -5
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/middlewares/scope.py +5 -3
- {python_cq-0.7.3 → python_cq-0.7.4}/pyproject.toml +1 -1
- {python_cq-0.7.3 → python_cq-0.7.4}/.gitignore +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/LICENSE +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/README.md +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/__init__.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/__init__.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/dispatcher/__init__.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/dispatcher/base.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/dispatcher/bus.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/dispatcher/pipe.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/handler.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/middleware.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/related_events.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/_core/scope.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/exceptions.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/middlewares/__init__.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/middlewares/retry.py +0 -0
- {python_cq-0.7.3 → python_cq-0.7.4}/cq/py.typed +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any, Final
|
|
2
2
|
|
|
3
3
|
import injection
|
|
4
4
|
|
|
@@ -22,23 +22,24 @@ type QueryBus[T] = Bus[Query, T]
|
|
|
22
22
|
AnyCommandBus = CommandBus[Any]
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
command_handler: HandlerDecorator[Command, Any] = HandlerDecorator(
|
|
25
|
+
command_handler: Final[HandlerDecorator[Command, Any]] = HandlerDecorator(
|
|
26
26
|
SingleHandlerManager(),
|
|
27
27
|
)
|
|
28
|
-
event_handler: HandlerDecorator[Event, None] = HandlerDecorator(
|
|
28
|
+
event_handler: Final[HandlerDecorator[Event, None]] = HandlerDecorator(
|
|
29
29
|
MultipleHandlerManager(),
|
|
30
30
|
)
|
|
31
|
-
query_handler: HandlerDecorator[Query, Any] = HandlerDecorator(
|
|
31
|
+
query_handler: Final[HandlerDecorator[Query, Any]] = HandlerDecorator(
|
|
32
32
|
SingleHandlerManager(),
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
@injection.injectable(inject=False, mode="fallback")
|
|
37
|
-
def new_command_bus() -> CommandBus: # type: ignore[type-arg]
|
|
37
|
+
def new_command_bus(*, threadsafe: bool | None = None) -> CommandBus: # type: ignore[type-arg]
|
|
38
38
|
bus = SimpleBus(command_handler.manager)
|
|
39
39
|
transaction_scope_middleware = InjectionScopeMiddleware(
|
|
40
40
|
CQScope.TRANSACTION,
|
|
41
41
|
exist_ok=True,
|
|
42
|
+
threadsafe=threadsafe,
|
|
42
43
|
)
|
|
43
44
|
bus.add_middlewares(transaction_scope_middleware)
|
|
44
45
|
return bus
|
|
@@ -21,11 +21,13 @@ class InjectionScopeMiddleware:
|
|
|
21
21
|
|
|
22
22
|
async def __call__(self, *args: Any, **kwargs: Any) -> MiddlewareResult[Any]:
|
|
23
23
|
async with AsyncExitStack() as stack:
|
|
24
|
-
|
|
24
|
+
cm = adefine_scope(self.scope_name, threadsafe=self.threadsafe)
|
|
25
25
|
try:
|
|
26
|
-
await stack.enter_async_context(
|
|
26
|
+
await stack.enter_async_context(cm)
|
|
27
|
+
|
|
27
28
|
except ScopeAlreadyDefinedError:
|
|
28
29
|
if not self.exist_ok:
|
|
29
30
|
raise
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
del cm
|
|
31
33
|
yield
|
|
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
|
|
File without changes
|