Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
83557a4
Fix `idom.run` uvicorn self.servers exception
Archmonger Feb 27, 2023
284bece
Merge branch 'main' into fix-idom-run-uvicorn
Archmonger Mar 1, 2023
ba0c95b
`started` compatibility
Archmonger Mar 1, 2023
e4b0b72
Merge branch 'main' into fix-idom-run-uvicorn
Archmonger Mar 1, 2023
635cd55
Merge branch 'main' into fix-idom-run-uvicorn
rmorshea Mar 2, 2023
c636223
Merge branch 'main' into fix-idom-run-uvicorn
Archmonger Mar 3, 2023
0b47b0f
try fixing tests
Archmonger Mar 3, 2023
4ae0932
Merge branch 'fix-idom-run-uvicorn' of https://github.com/Archmonger/…
Archmonger Mar 3, 2023
0c3a91a
use exception suppression
Archmonger Mar 3, 2023
8f4ac8c
try again
Archmonger Mar 3, 2023
1657b89
try again
Archmonger Mar 3, 2023
74f5298
try alternative shutdown
Archmonger Mar 3, 2023
15a0eae
Revert "try alternative shutdown"
Archmonger Mar 3, 2023
55ecd27
use hasattr
Archmonger Mar 4, 2023
8ffcf8b
remove victorybar tests
Archmonger Mar 4, 2023
f70d99d
add no cov
Archmonger Mar 4, 2023
47913b3
Merge branch 'main' into fix-idom-run-uvicorn
rmorshea Mar 28, 2023
4ed3cae
change pragmas
Archmonger Mar 29, 2023
bb2732c
remove module_from_template
Archmonger Mar 29, 2023
96d28c1
try to fix tests
Archmonger Mar 29, 2023
22126df
remove dead file
Archmonger Mar 29, 2023
2175254
add changelog entry
Archmonger Mar 29, 2023
bdf96f6
add no covers
Archmonger Mar 31, 2023
b18ccaa
move pragmas around
Archmonger Mar 31, 2023
0939200
fix mypy warning
Archmonger Apr 1, 2023
daa90c7
more mypy fixes
Archmonger Apr 1, 2023
89f434f
undo `module_from_template` removal
Archmonger Apr 4, 2023
e4d213a
Merge remote-tracking branch 'upstream/main' into fix-idom-run-uvicorn
Archmonger Apr 4, 2023
14c4da5
fix style
Archmonger Apr 4, 2023
f1b9e37
try to remove some pragmas
Archmonger Apr 4, 2023
ea33932
more logical if statement
Archmonger Apr 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/reactpy/backend/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from typing import Any, Awaitable, Sequence, cast

from asgiref.typing import ASGIApplication
from uvicorn.config import Config as UvicornConfig
from uvicorn.server import Server as UvicornServer
import uvicorn

from reactpy import __file__ as _reactpy_file_path
from reactpy import html
Expand All @@ -31,29 +30,32 @@ async def serve_development_asgi(
port: int,
started: asyncio.Event | None,
) -> None:
"""Run a development server for starlette"""
server = UvicornServer(
UvicornConfig(
"""Run a development server for an ASGI application"""
server = uvicorn.Server(
uvicorn.Config(
app,
host=host,
port=port,
loop="asyncio",
reload=True,
)
)

server.config.setup_event_loop()
coros: list[Awaitable[Any]] = [server.serve()]

# If a started event is provided, then use it signal based on `server.started`
if started:
coros.append(_check_if_started(server, started))

try:
await asyncio.gather(*coros)
finally:
if not hasattr(server, "servers"): # pragma: no cover
server.servers = []
await asyncio.wait_for(server.shutdown(), timeout=3)


async def _check_if_started(server: UvicornServer, started: asyncio.Event) -> None:
async def _check_if_started(server: uvicorn.Server, started: asyncio.Event) -> None:
while not server.started:
await asyncio.sleep(0.2)
started.set()
Expand Down
7 changes: 0 additions & 7 deletions tests/test_backend/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ def Counter():
await counter.click()


async def test_module_from_template(display: DisplayFixture):
victory = reactpy.web.module_from_template("react", "[email protected]")
VictoryBar = reactpy.web.export(victory, "VictoryBar")
await display.show(VictoryBar)
await display.page.wait_for_selector(".VictoryContainer")


async def test_use_connection(display: DisplayFixture):
conn = reactpy.Ref()

Expand Down
15 changes: 0 additions & 15 deletions tests/test_web/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,6 @@ def ShowSimpleButton():
await display.page.wait_for_selector("#my-button")


def test_module_from_template_where_template_does_not_exist():
with pytest.raises(ValueError, match="No template for 'does-not-exist.js'"):
reactpy.web.module_from_template("does-not-exist", "something.js")


async def test_module_from_template(display: DisplayFixture):
victory = reactpy.web.module_from_template("[email protected]", "[email protected]")

assert "[email protected]" in victory.file.read_text()
VictoryBar = reactpy.web.export(victory, "VictoryBar")
await display.show(VictoryBar)

await display.page.wait_for_selector(".VictoryContainer")


async def test_module_from_file(display: DisplayFixture):
SimpleButton = reactpy.web.export(
reactpy.web.module_from_file(
Expand Down