Skip to content

Commit e29745e

Browse files
committed
do not call find_builtin_server_type at import time
1 parent 8f81ce4 commit e29745e

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/idom/client/app/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/idom/server/prefab.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from .utils import find_available_port, find_builtin_server_type
1414

1515

16-
DEFAULT_SERVER_FACTORY = find_builtin_server_type("PerClientStateServer")
17-
1816
logger = logging.getLogger(__name__)
1917

2018
_App = TypeVar("_App")
@@ -23,7 +21,7 @@
2321

2422
def run(
2523
component: ComponentConstructor,
26-
server_type: ServerFactory[_App, _Config] = DEFAULT_SERVER_FACTORY,
24+
server_type: Optional[ServerFactory[_App, _Config]] = None,
2725
host: str = "127.0.0.1",
2826
port: Optional[int] = None,
2927
server_config: Optional[Any] = None,
@@ -57,8 +55,8 @@ def run(
5755
The server instance. This isn't really useful unless the server is spawned
5856
as a daemon. Otherwise this function blocks until the server has stopped.
5957
"""
60-
if server_type is None: # pragma: no cover
61-
raise ValueError("No default server available.")
58+
if server_type is None:
59+
server_type = find_builtin_server_type("PerClientStateServer")
6260
if port is None: # pragma: no cover
6361
port = find_available_port(host)
6462

@@ -73,7 +71,7 @@ def run(
7371

7472

7573
def multiview_server(
76-
server_type: ServerFactory[_App, _Config] = DEFAULT_SERVER_FACTORY,
74+
server_type: Optional[ServerFactory[_App, _Config]] = None,
7775
host: str = "127.0.0.1",
7876
port: Optional[int] = None,
7977
server_config: Optional[_Config] = None,
@@ -115,7 +113,7 @@ def multiview_server(
115113

116114

117115
def hotswap_server(
118-
server_type: ServerFactory[_App, _Config] = DEFAULT_SERVER_FACTORY,
116+
server_type: Optional[ServerFactory[_App, _Config]] = None,
119117
host: str = "127.0.0.1",
120118
port: Optional[int] = None,
121119
server_config: Optional[_Config] = None,

src/idom/server/utils.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ def poll(
5858

5959

6060
def find_builtin_server_type(type_name: str) -> ServerFactory[Any, Any]:
61-
"""Find first installed server implementation"""
61+
"""Find first installed server implementation
62+
63+
Raises:
64+
:class:`RuntimeError` if one cannot be found
65+
"""
6266
installed_builtins: List[str] = []
6367
for name in _SUPPORTED_PACKAGES:
6468
try:

src/idom/testing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from idom.core.events import EventHandler
2929
from idom.core.hooks import LifeCycleHook, current_hook
3030
from idom.core.utils import hex_id
31-
from idom.server.prefab import DEFAULT_SERVER_FACTORY, hotswap_server
31+
from idom.server.prefab import hotswap_server
3232
from idom.server.proto import Server, ServerFactory
3333
from idom.server.utils import find_available_port
3434

@@ -73,7 +73,7 @@ class ServerMountPoint(Generic[_Mount, _Server]):
7373

7474
def __init__(
7575
self,
76-
server_type: ServerFactory[_App, _Config] = DEFAULT_SERVER_FACTORY,
76+
server_type: Optional[ServerFactory[_App, _Config]] = None,
7777
host: str = "127.0.0.1",
7878
port: Optional[int] = None,
7979
server_config: Optional[_Config] = None,

0 commit comments

Comments
 (0)