5555import uuid
5656
5757# Third-Party
58+ import uvicorn
59+ from sse_starlette .sse import EventSourceResponse
5860from fastapi import FastAPI , Request , Response , status
5961from fastapi .middleware .cors import CORSMiddleware
6062from fastapi .responses import PlainTextResponse
61- from sse_starlette .sse import EventSourceResponse
62- import uvicorn
6363
6464try :
6565 # Third-Party
@@ -135,7 +135,7 @@ async def start(self) -> None:
135135
136136 Creates the subprocess and starts the stdout pump task.
137137 """
138- LOGGER .info ("Starting stdio subprocess: %s" , self ._cmd )
138+ LOGGER .info (f "Starting stdio subprocess: { self ._cmd } " )
139139 self ._proc = await asyncio .create_subprocess_exec (
140140 * shlex .split (self ._cmd ),
141141 stdin = asyncio .subprocess .PIPE ,
@@ -153,7 +153,7 @@ async def stop(self) -> None:
153153 """
154154 if self ._proc is None :
155155 return
156- LOGGER .info ("Stopping subprocess (pid=%s)" , self ._proc .pid )
156+ LOGGER .info (f "Stopping subprocess (pid={ self ._proc .pid } )" )
157157 self ._proc .terminate ()
158158 with suppress (asyncio .TimeoutError ):
159159 await asyncio .wait_for (self ._proc .wait (), timeout = 5 )
@@ -171,7 +171,7 @@ async def send(self, raw: str) -> None:
171171 """
172172 if not self ._stdin :
173173 raise RuntimeError ("stdio endpoint not started" )
174- LOGGER .debug ("→ stdio: %s" , raw .strip ())
174+ LOGGER .debug (f "→ stdio: { raw .strip ()} " )
175175 self ._stdin .write (raw .encode ())
176176 await self ._stdin .drain ()
177177
@@ -192,7 +192,7 @@ async def _pump_stdout(self) -> None:
192192 if not line : # EOF
193193 break
194194 text = line .decode (errors = "replace" )
195- LOGGER .debug ("← stdio: %s" , text .strip ())
195+ LOGGER .debug (f "← stdio: { text .strip ()} " )
196196 await self ._pubsub .publish (text )
197197 except Exception : # pragma: no cover --best-effort logging
198198 LOGGER .exception ("stdout pump crashed - terminating bridge" )
@@ -420,7 +420,7 @@ async def _shutdown() -> None:
420420 with suppress (NotImplementedError ): # Windows lacks add_signal_handler
421421 loop .add_signal_handler (sig , lambda : asyncio .create_task (_shutdown ()))
422422
423- LOGGER .info ("Bridge ready → http://127.0.0.1:%s /sse" , port )
423+ LOGGER .info (f "Bridge ready → http://127.0.0.1:{ port } /sse" )
424424 await server .serve ()
425425 await _shutdown () # final cleanup
426426
0 commit comments