Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/labthings_fastapi/server/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"""
if args.config:
if args.json:
raise RuntimeError("Can't use both --config and --json simultaneously.")

Check warning on line 102 in src/labthings_fastapi/server/cli.py

View workflow job for this annotation

GitHub Actions / coverage

102 line is not covered with tests
try:
with open(args.config) as f:
return ThingServerConfig.model_validate_json(f.read())
Expand Down Expand Up @@ -161,7 +161,7 @@
server = ThingServer.from_config(config, True if args.debug else False)
if dry_run:
return server
uvicorn.run(server.app, host=args.host, port=args.port)
uvicorn.run(server.app, host=args.host, port=args.port, ws="websockets-sansio")
except BaseException as e:
if args.fallback:
print(f"Error: {e}")
Expand All @@ -174,11 +174,11 @@
)
)

uvicorn.run(app, host=args.host, port=args.port)
uvicorn.run(app, host=args.host, port=args.port, ws="websockets-sansio")
else:
if isinstance(e, (ValidationError, ThingImportFailure)):
print(f"Error reading LabThings configuration:\n{e}")
sys.exit(3)
else:
raise e
return None # This is required as we sometimes return the server

Check warning on line 184 in src/labthings_fastapi/server/cli.py

View workflow job for this annotation

GitHub Actions / coverage

184 line is not covered with tests
2 changes: 1 addition & 1 deletion tests/test_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_actual_server_fallback():

# Starting the server is a SystemExit
with pytest.raises(SystemExit, match="3") as excinfo:
uvicorn.run(server.app, port=5000)
uvicorn.run(server.app, port=5000, ws="websockets-sansio")
server_error = excinfo.value
assert server.startup_failure is not None
assert server.startup_failure["thing"] == "bad_thing"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mjpeg_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ def test_mjpeg_stream(client):
assert isinstance(telly, Telly)
telly.framerate = 6
telly.frame_limit = -1
uvicorn.run(server.app, port=5000)
uvicorn.run(server.app, port=5000, ws="websockets-sansio")