Skip to content

Commit 69238e0

Browse files
committed
upgrade anyio - see agronholm/anyio#155
1 parent 3c5c31a commit 69238e0

File tree

2 files changed

+5
-29
lines changed

2 files changed

+5
-29
lines changed

Diff for: idom/core/dispatcher.py

+4-28
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import abc
22
import asyncio
3-
from functools import wraps
4-
from typing import Callable, Awaitable, Dict, Any, AsyncIterator, TypeVar, cast
3+
from typing import Callable, Awaitable, Dict, Any, AsyncIterator
54

65
from anyio import create_task_group, TaskGroup # type: ignore
76
from jsonpatch import make_patch, apply_patch
8-
from loguru import logger
97

108
from .layout import (
119
LayoutEvent,
1210
LayoutUpdate,
1311
Layout,
14-
Layout,
1512
)
1613
from .utils import HasAsyncResources, async_resource
1714

@@ -44,12 +41,8 @@ async def run(self, send: SendCoroutine, recv: RecvCoroutine, context: Any) -> N
4441
This will call :meth:`AbstractLayouTaskGroupTaskGroupt.render` and :meth:`Layout.dispatch`
4542
to render new models and execute events respectively.
4643
"""
47-
await self.task_group.spawn(
48-
_async_log_exceptions(self._outgoing_loop), send, context
49-
)
50-
await self.task_group.spawn(
51-
_async_log_exceptions(self._incoming_loop), recv, context
52-
)
44+
await self.task_group.spawn(self._outgoing_loop, send, context)
45+
await self.task_group.spawn(self._incoming_loop, recv, context)
5346
return None
5447

5548
async def _outgoing_loop(self, send: SendCoroutine, context: Any) -> None:
@@ -108,7 +101,7 @@ def __init__(self, layout: Layout) -> None:
108101
@async_resource
109102
async def task_group(self) -> AsyncIterator[TaskGroup]:
110103
async with create_task_group() as group:
111-
await group.spawn(_async_log_exceptions(self._render_loop))
104+
await group.spawn(self._render_loop)
112105
yield group
113106

114107
async def run(
@@ -147,20 +140,3 @@ def _apply_layout_update(doc: Dict[str, Any], update: LayoutUpdate) -> Any:
147140
return apply_patch(
148141
doc, [{**c, "path": update.path + c["path"]} for c in update.changes]
149142
)
150-
151-
152-
_F = TypeVar("_F", bound=Callable[..., Any])
153-
154-
155-
def _async_log_exceptions(function: _F) -> _F:
156-
# BUG: https://github.com/agronholm/anyio/issues/155
157-
158-
@wraps(function)
159-
async def wrapper(*args: Any, **kwargs: Any) -> Any:
160-
try:
161-
return await function(*args, **kwargs)
162-
except Exception:
163-
logger.exception(f"Failure in {function}")
164-
raise
165-
166-
return cast(_F, wrapper)

Diff for: requirements/prod.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
loguru >=0.3.2
22
typing-extensions >=3.7.4
33
mypy-extensions >=0.4.3
4-
anyio >=1.3.0
4+
anyio >=1.4.0
55
async_generator >=1.10; python_version<"3.7"
66
async_exit_stack >=1.0.1; python_version<"3.7"
77
jsonpatch >=1.26

0 commit comments

Comments
 (0)