|
1 | 1 | import abc
|
2 | 2 | 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 |
5 | 4 |
|
6 | 5 | from anyio import create_task_group, TaskGroup # type: ignore
|
7 | 6 | from jsonpatch import make_patch, apply_patch
|
8 |
| -from loguru import logger |
9 | 7 |
|
10 | 8 | from .layout import (
|
11 | 9 | LayoutEvent,
|
12 | 10 | LayoutUpdate,
|
13 | 11 | Layout,
|
14 |
| - Layout, |
15 | 12 | )
|
16 | 13 | from .utils import HasAsyncResources, async_resource
|
17 | 14 |
|
@@ -44,12 +41,8 @@ async def run(self, send: SendCoroutine, recv: RecvCoroutine, context: Any) -> N
|
44 | 41 | This will call :meth:`AbstractLayouTaskGroupTaskGroupt.render` and :meth:`Layout.dispatch`
|
45 | 42 | to render new models and execute events respectively.
|
46 | 43 | """
|
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) |
53 | 46 | return None
|
54 | 47 |
|
55 | 48 | async def _outgoing_loop(self, send: SendCoroutine, context: Any) -> None:
|
@@ -108,7 +101,7 @@ def __init__(self, layout: Layout) -> None:
|
108 | 101 | @async_resource
|
109 | 102 | async def task_group(self) -> AsyncIterator[TaskGroup]:
|
110 | 103 | async with create_task_group() as group:
|
111 |
| - await group.spawn(_async_log_exceptions(self._render_loop)) |
| 104 | + await group.spawn(self._render_loop) |
112 | 105 | yield group
|
113 | 106 |
|
114 | 107 | async def run(
|
@@ -147,20 +140,3 @@ def _apply_layout_update(doc: Dict[str, Any], update: LayoutUpdate) -> Any:
|
147 | 140 | return apply_patch(
|
148 | 141 | doc, [{**c, "path": update.path + c["path"]} for c in update.changes]
|
149 | 142 | )
|
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) |
0 commit comments