MCPcopy
hub / github.com/encode/uvicorn / __call__

Method __call__

uvicorn/middleware/wsgi.py:120–144  ·  view source on GitHub ↗
(self, receive: ASGIReceiveCallable, send: ASGISendCallable)

Source from the content-addressed store, hash-verified

118 self.exc_info: ExcInfo | None = None
119
120 async def __call__(self, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None:
121 message: HTTPRequestEvent = await receive() # type: ignore[assignment]
122 body = io.BytesIO(message.get("body", b""))
123 more_body = message.get("more_body", False)
124 if more_body:
125 body.seek(0, io.SEEK_END)
126 while more_body:
127 body_message: HTTPRequestEvent = (
128 await receive() # type: ignore[assignment]
129 )
130 body.write(body_message.get("body", b""))
131 more_body = body_message.get("more_body", False)
132 body.seek(0)
133 environ = build_environ(self.scope, message, body)
134 self.loop = asyncio.get_event_loop()
135 wsgi = self.loop.run_in_executor(self.executor, self.wsgi, environ, self.start_response)
136 sender = self.loop.create_task(self.sender(send))
137 try:
138 await asyncio.wait_for(wsgi, None)
139 finally:
140 self.send_queue.append(None)
141 self.send_event.set()
142 await asyncio.wait_for(sender, None)
143 if self.exc_info is not None:
144 raise self.exc_info[0].with_traceback(self.exc_info[1], self.exc_info[2])
145
146 async def sender(self, send: ASGISendCallable) -> None:
147 while True:

Callers

nothing calls this directly

Calls 4

senderMethod · 0.95
build_environFunction · 0.85
writeMethod · 0.45
create_taskMethod · 0.45

Tested by

no test coverage detected