MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / handle_request

Method handle_request

tests/autoalloc/mock/mock.py:126–146  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

124 stop_signal: Optional[asyncio.Queue] = None
125
126 async def handle_request(request):
127 command = request.match_info["cmd"]
128 request_key = request.headers["HQ_TEST_KEY"]
129 assert request_key == key
130
131 logging.info(f"Received request: {request}, command: {command}")
132 input = await extract_mock_input(request, command)
133 try:
134 resp = await handler.handle_command(input)
135 except ManagerException as e:
136 # This exception should not be propagated within tests, and should be returned
137 # in stderr of the manager response instead.
138 resp = response_error(stderr=str(e))
139 assert isinstance(resp, CommandOutput)
140
141 resp = {
142 "stdout": resp.stdout,
143 "stderr": resp.stderr,
144 "code": resp.code,
145 }
146 return web.json_response(resp)
147
148 @web.middleware
149 async def handle_error(request, handler):

Callers

nothing calls this directly

Calls 4

extract_mock_inputFunction · 0.85
response_errorFunction · 0.85
infoMethod · 0.80
handle_commandMethod · 0.80

Tested by

no test coverage detected