Skip to content

Commit d63d3d4

Browse files
committed
misc fixes
1 parent 0dc1eaa commit d63d3d4

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

Diff for: docs/source/about/changelog.rst

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Unreleased
4545
``something if condition else html._()``. Now you can simply write
4646
``something if condition else None``.
4747

48+
**Deprecated**
49+
50+
- :pull:`1171` - The ``Stop`` exception. Recent releases of ``anyio`` have made this
51+
exception difficult to use since it now raises an ``ExceptionGroup``. This exception
52+
was primarily used for internal testing purposes and so is now deprecated.
53+
4854

4955
v1.0.2
5056
------

Diff for: src/py/reactpy/reactpy/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use_state,
1717
)
1818
from reactpy.core.layout import Layout
19-
from reactpy.core.serve import Stop
2019
from reactpy.core.vdom import vdom
2120
from reactpy.utils import Ref, html_to_vdom, vdom_to_html
2221

Diff for: src/py/reactpy/reactpy/core/serve.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from collections.abc import Awaitable
44
from logging import getLogger
55
from typing import Callable
6+
from warnings import warn
67

78
from anyio import create_task_group
89
from anyio.abc import TaskGroup
@@ -24,7 +25,9 @@
2425

2526

2627
class Stop(BaseException):
27-
"""Stop serving changes and events
28+
"""Deprecated
29+
30+
Stop serving changes and events
2831
2932
Raising this error will tell dispatchers to gracefully exit. Typically this is
3033
called by code running inside a layout to tell it to stop rendering.
@@ -42,7 +45,12 @@ async def serve_layout(
4245
async with create_task_group() as task_group:
4346
task_group.start_soon(_single_outgoing_loop, layout, send)
4447
task_group.start_soon(_single_incoming_loop, task_group, layout, recv)
45-
except Stop:
48+
except Stop: # nocov
49+
warn(
50+
"The Stop exception is deprecated and will be removed in a future version",
51+
UserWarning,
52+
stacklevel=1,
53+
)
4654
logger.info(f"Stopped serving {layout}")
4755

4856

Diff for: src/py/reactpy/tests/test_core/test_serve.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from collections.abc import Sequence
33
from typing import Any
44

5+
import pytest
56
from jsonpointer import set_pointer
67

78
import reactpy
@@ -17,6 +18,10 @@
1718
STATIC_EVENT_HANDLER = StaticEventHandler()
1819

1920

21+
class StopError(Exception):
22+
"""Stop the dispatcher"""
23+
24+
2025
def make_send_recv_callbacks(events_to_inject):
2126
changes = []
2227

@@ -31,7 +36,7 @@ async def send(patch):
3136
changes.append(patch)
3237
sem.release()
3338
if not events_to_inject:
34-
raise reactpy.Stop()
39+
raise StopError()
3540

3641
async def recv():
3742
await sem.acquire()
@@ -93,7 +98,8 @@ def Counter():
9398
async def test_dispatch():
9499
events, expected_model = make_events_and_expected_model()
95100
changes, send, recv = make_send_recv_callbacks(events)
96-
await asyncio.wait_for(serve_layout(Layout(Counter()), send, recv), 1)
101+
with pytest.raises(StopError):
102+
await asyncio.wait_for(serve_layout(Layout(Counter()), send, recv), 1)
97103
assert_changes_produce_expected_model(changes, expected_model)
98104

99105

0 commit comments

Comments
 (0)