@@ -18,9 +18,9 @@ class AbstractRenderServer(Generic[_App, _Config], abc.ABC):
18
18
standalone and as an extension to an existing application.
19
19
20
20
Standalone usage:
21
- :meth:`AbstractServerExtension.run` or :meth:`AbstractServerExtension.daemon `
21
+ :meth:`~ AbstractServerExtension.run` or :meth:`~ AbstractServerExtension.run_in_thread `
22
22
Register an extension:
23
- :meth:`AbstractServerExtension.register`
23
+ :meth:`~ AbstractServerExtension.register`
24
24
"""
25
25
26
26
def __init__ (
@@ -54,7 +54,7 @@ def run(self, host: str, port: int, *args: Any, **kwargs: Any) -> None:
54
54
self ._config , app , host , port , args , kwargs
55
55
)
56
56
57
- def daemon (self , * args : Any , ** kwargs : Any ) -> Thread :
57
+ def run_in_thread (self , * args : Any , ** kwargs : Any ) -> Thread :
58
58
"""Run the standalone application in a seperate thread."""
59
59
self ._daemon_thread = thread = Thread (
60
60
target = lambda : self .run (* args , ** kwargs ), daemon = True
@@ -67,6 +67,8 @@ def daemon(self, *args: Any, **kwargs: Any) -> Thread:
67
67
68
68
def register (self : _Self , app : Optional [_App ]) -> _Self :
69
69
"""Register this as an extension."""
70
+ if self ._app is not None :
71
+ raise RuntimeError (f"Already registered { self ._app } " )
70
72
self ._setup_application (self ._config , app )
71
73
self ._setup_application_did_start_event (
72
74
self ._config , app , self ._server_did_start
@@ -84,10 +86,12 @@ def wait_until_server_start(self, timeout: float = 3.0) -> None:
84
86
@abc .abstractmethod
85
87
def stop (self ) -> None :
86
88
"""Stop a currently running application"""
89
+ raise NotImplementedError ()
87
90
88
91
@abc .abstractmethod
89
92
def _create_config (self , config : Optional [_Config ]) -> _Config :
90
93
"""Return the default configuration options."""
94
+ raise NotImplementedError ()
91
95
92
96
@abc .abstractmethod
93
97
def _default_application (self , config : _Config ) -> _App :
0 commit comments