Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 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
5 changes: 3 additions & 2 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2591,10 +2591,11 @@ int main(int argc, char ** argv) {
return false;
};

auto middleware_server_state = [&res_error, &state](const httplib::Request &, httplib::Response & res) {
auto middleware_server_state = [&state](const httplib::Request &, httplib::Response & res) {
server_state current_state = state.load();
if (current_state == SERVER_STATE_LOADING_MODEL) {
res_error(res, format_error_response("Loading model", ERROR_TYPE_UNAVAILABLE));
res.set_content("<html><body>The model is loading. Please wait.<br/>The user interface will appear soon.</body></html>", "text/html; charset=utf-8");
res.status = 503;
return false;
}
return true;
Expand Down
7 changes: 5 additions & 2 deletions examples/server/tests/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,10 @@ async def wait_for_slots_status(context,
while True:
async with await session.get(f'{base_url}/slots', params=params) as slots_response:
status_code = slots_response.status
slots = await slots_response.json()
try:
slots = await slots_response.json()
except:
slots = await slots_response.text()
if context.debug:
print(f"slots responses {slots}\n")
if status_code == 503 and status_code == expected_http_status_code:
Expand Down Expand Up @@ -1372,4 +1375,4 @@ def server_log(in_stream, out_stream):
thread_stderr = threading.Thread(target=server_log, args=(context.server_process.stderr, sys.stderr))
thread_stderr.start()

print(f"server pid={context.server_process.pid}, behave pid={os.getpid()}")
print(f"server pid={context.server_process.pid}, behave pid={os.getpid()}")