1919# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121# SOFTWARE.
22+ """Simple launcher for testing module."""
2223
2324import dataclasses
2425import pathlib
4041
4142@dataclasses .dataclass
4243class SimpleLauncherConfig :
44+ """Configuration for the SimpleLauncher."""
45+
4346 script_path : str = dataclasses .field (
4447 default = str (SCRIPT_PATH ),
4548 metadata = {METADATA_KEY_DOC : "Location of the server Python script." },
@@ -50,10 +53,13 @@ class SimpleLauncherConfig:
5053
5154
5255class SimpleLauncher (LauncherProtocol [SimpleLauncherConfig ]):
56+ """Simple launcher for testing."""
57+
5358 CONFIG_MODEL = SimpleLauncherConfig
5459 SERVER_SPEC = {SERVER_KEY : ServerType .GRPC }
5560
5661 def __init__ (self , * , config : SimpleLauncherConfig ):
62+ """Initialize the SimpleLauncher with the given configuration."""
5763 self ._script_path = config .script_path
5864 self ._transport_options = config .transport_options
5965 if self ._transport_options .mode != "uds" :
@@ -69,6 +75,7 @@ def __init__(self, *, config: SimpleLauncherConfig):
6975 self ._url = f"unix:{ self ._uds_file } "
7076
7177 def start (self ):
78+ """Start the service."""
7279 self ._process = subprocess .Popen (
7380 [
7481 sys .executable ,
@@ -81,6 +88,7 @@ def start(self):
8188 )
8289
8390 def stop (self , * , timeout = None ):
91+ """Stop the service."""
8492 self ._process .terminate ()
8593 try :
8694 self ._process .wait (timeout = timeout )
@@ -92,9 +100,11 @@ def stop(self, *, timeout=None):
92100 self ._uds_file .unlink (missing_ok = True )
93101
94102 def check (self , * , timeout : float | None = None ) -> bool :
95- channel = self ._transport_options .create_channel ()
103+ """Check if the server is responding to requests."""
104+ channel = grpc .insecure_channel (self .urls [SERVER_KEY ])
96105 return check_grpc_health (channel , timeout = timeout )
97106
98107 @property
99- def transport_options (self ):
100- return {SERVER_KEY : self ._transport_options }
108+ def urls (self ):
109+ """Return the URLs of the server."""
110+ return {SERVER_KEY : self ._url }
0 commit comments