Skip to content

Commit

Permalink
recactor sanic server
Browse files Browse the repository at this point in the history
this greatly simplifies the underlying implementation
by avoiding any reliance on inheritance
  • Loading branch information
rmorshea committed May 16, 2021
1 parent abe0fde commit 43d4b4f
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 165 deletions.
1 change: 1 addition & 0 deletions scripts/live_docs.py
Expand Up @@ -40,6 +40,7 @@ def new_builder():
server = PerClientStateServer(main.component, {"cors": True})
_running_idom_servers.append(server)
server.run_in_thread("127.0.0.1", 5555, debug=True)
server.wait_until_started()
old_builder()

return new_builder
Expand Down
8 changes: 4 additions & 4 deletions src/idom/core/dispatcher.py
Expand Up @@ -42,8 +42,8 @@ async def dispatch_single_view(
task_group.start_soon(_single_incoming_loop, layout, recv)


SharedViewDispatcher = Callable[[SendCoroutine, RecvCoroutine], Awaitable[None]]
_SharedViewDispatcherFuture = Callable[[SendCoroutine, RecvCoroutine], "Future[None]"]
_SharedViewDispatcherCoro = Callable[[SendCoroutine, RecvCoroutine], Awaitable[None]]


@asynccontextmanager
Expand Down Expand Up @@ -93,8 +93,8 @@ def dispatch_shared_view_soon(

def ensure_shared_view_dispatcher_future(
layout: Layout,
) -> Tuple[Future[None], _SharedViewDispatcherCoro]:
dispatcher_future: Future[_SharedViewDispatcherCoro] = Future()
) -> Tuple[Future[None], SharedViewDispatcher]:
dispatcher_future: Future[SharedViewDispatcher] = Future()

async def dispatch_shared_view_forever() -> None:
with layout:
Expand All @@ -121,7 +121,7 @@ async def dispatch(send: SendCoroutine, recv: RecvCoroutine) -> None:

async def _make_shared_view_dispatcher(
layout: Layout,
) -> Tuple[_SharedViewDispatcherCoro, Ref[Any], WeakSet[Queue[LayoutUpdate]]]:
) -> Tuple[SharedViewDispatcher, Ref[Any], WeakSet[Queue[LayoutUpdate]]]:
initial_update = await layout.render()
model_state = Ref(initial_update.apply_to({}))

Expand Down
1 change: 1 addition & 0 deletions src/idom/server/prefab.py
Expand Up @@ -67,6 +67,7 @@ def run(

run_server = server.run if not daemon else server.run_in_thread
run_server(host, port, **(run_kwargs or {})) # type: ignore
server.wait_until_started()

return server

Expand Down
2 changes: 1 addition & 1 deletion src/idom/server/proto.py
Expand Up @@ -7,7 +7,7 @@

try:
from typing import Protocol
except ImportError:
except ImportError: # pragma: no cover
from typing_extensions import Protocol # type: ignore


Expand Down

0 comments on commit 43d4b4f

Please sign in to comment.