python-cq 0.11.1__tar.gz → 0.11.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.
- {python_cq-0.11.1 → python_cq-0.11.3}/PKG-INFO +1 -1
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/related_events.py +13 -9
- python_cq-0.11.3/cq/_core/scope.py +5 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/pyproject.toml +1 -1
- python_cq-0.11.1/cq/_core/scope.py +0 -5
- {python_cq-0.11.1 → python_cq-0.11.3}/.gitignore +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/LICENSE +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/README.md +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/__init__.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/__init__.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/dispatcher/__init__.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/dispatcher/base.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/dispatcher/bus.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/dispatcher/lazy.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/dispatcher/pipe.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/handler.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/message.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/middleware.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/_core/pipetools.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/exceptions.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/ext/__init__.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/ext/fastapi.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/middlewares/__init__.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/middlewares/retry.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/middlewares/scope.py +0 -0
- {python_cq-0.11.1 → python_cq-0.11.3}/cq/py.typed +0 -0
|
@@ -5,6 +5,7 @@ from typing import Protocol, runtime_checkable
|
|
|
5
5
|
|
|
6
6
|
import anyio
|
|
7
7
|
import injection
|
|
8
|
+
from anyio.abc import TaskGroup
|
|
8
9
|
|
|
9
10
|
from cq._core.message import Event, EventBus
|
|
10
11
|
from cq._core.scope import CQScope
|
|
@@ -20,20 +21,23 @@ class RelatedEvents(Protocol):
|
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
@dataclass(repr=False, eq=False, frozen=True, slots=True)
|
|
23
|
-
class
|
|
24
|
-
|
|
24
|
+
class AnyIORelatedEvents(RelatedEvents):
|
|
25
|
+
event_bus: EventBus
|
|
26
|
+
task_group: TaskGroup
|
|
27
|
+
history: list[Event] = field(default_factory=list, init=False)
|
|
25
28
|
|
|
26
|
-
def __bool__(self) -> bool:
|
|
27
|
-
return bool(self.
|
|
29
|
+
def __bool__(self) -> bool: # pragma: no cover
|
|
30
|
+
return bool(self.history)
|
|
28
31
|
|
|
29
32
|
def add(self, *events: Event) -> None:
|
|
30
|
-
self.
|
|
33
|
+
self.history.extend(events)
|
|
34
|
+
dispatch_method = self.event_bus.dispatch
|
|
35
|
+
|
|
36
|
+
for event in events:
|
|
37
|
+
self.task_group.start_soon(dispatch_method, event)
|
|
31
38
|
|
|
32
39
|
|
|
33
40
|
@injection.scoped(CQScope.TRANSACTION, mode="fallback")
|
|
34
41
|
async def related_events_recipe(event_bus: EventBus) -> AsyncIterator[RelatedEvents]:
|
|
35
|
-
yield (instance := SimpleRelatedEvents())
|
|
36
|
-
|
|
37
42
|
async with anyio.create_task_group() as task_group:
|
|
38
|
-
|
|
39
|
-
task_group.start_soon(event_bus.dispatch, event)
|
|
43
|
+
yield AnyIORelatedEvents(event_bus, task_group)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|