MCPcopy Index your code
hub / github.com/python-websockets/websockets / process_request

Method process_request

tests/asyncio/test_client.py:167–179  ·  view source on GitHub ↗
(connection, request)

Source from the content-addressed store, hash-verified

165 successful = 0
166
167 async def process_request(connection, request):
168 nonlocal iterations
169 iterations += 1
170 # Retriable errors
171 if iterations == 1:
172 await asyncio.sleep(3 * MS)
173 elif iterations == 2:
174 connection.transport.close()
175 elif iterations == 3:
176 return connection.respond(http.HTTPStatus.SERVICE_UNAVAILABLE, "🚒")
177 # Fatal error
178 elif iterations == 6:
179 return connection.respond(http.HTTPStatus.PAYMENT_REQUIRED, "💸")
180
181 async with serve(*args, process_request=process_request) as server:
182 with self.assertRaises(InvalidStatus) as raised:

Callers

nothing calls this directly

Calls 2

closeMethod · 0.45
respondMethod · 0.45

Tested by

no test coverage detected