Skip to content

Commit 796259c

Browse files
committed
Changed FileServer to run as one-shot and added lowercase handling to the EVAL_IO env var
1 parent 3c9c94c commit 796259c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lf_toolkit/io/serve.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from anyio.abc import CancelScope
77

88
from .base_server import BaseServer
9+
from .file_server import FileServer
910

1011

1112
async def signal_handler(scope: CancelScope):
@@ -22,9 +23,12 @@ async def signal_handler(scope: CancelScope):
2223

2324
def run(server: BaseServer):
2425
async def main():
25-
async with anyio.create_task_group() as tg:
26-
tg.start_soon(signal_handler, tg.cancel_scope)
27-
tg.start_soon(server.run)
26+
if isinstance(server, FileServer):
27+
await server.run()
28+
else:
29+
async with anyio.create_task_group() as tg:
30+
tg.start_soon(signal_handler, tg.cancel_scope)
31+
tg.start_soon(server.run)
2832

2933
anyio.run(main)
3034

@@ -38,7 +42,7 @@ async def main():
3842

3943

4044
def create_server():
41-
io = os.environ.get("EVAL_IO", "rpc")
45+
io = os.environ.get("EVAL_IO", "rpc").lower()
4246

4347
if io == "rpc":
4448
return create_rpc_server()

0 commit comments

Comments
 (0)