예제 #1
0
 async def _server_request_loop(
         self, delegate: httputil.HTTPServerConnectionDelegate) -> None:
     try:
         while True:
             conn = HTTP1Connection(self.stream, False, self.params,
                                    self.context)
             request_delegate = delegate.start_request(self, conn)
             try:
                 ret = await conn.read_response(request_delegate)
             except (
                     iostream.StreamClosedError,
                     iostream.UnsatisfiableReadError,
                     asyncio.CancelledError,
             ):
                 return
             except _QuietException:
                 # This exception was already logged.
                 conn.close()
                 return
             except Exception:
                 gen_log.error("Uncaught exception", exc_info=True)
                 conn.close()
                 return
             if not ret:
                 return
             await asyncio.sleep(0)
     finally:
         delegate.on_close(self)
예제 #2
0
 async def _server_request_loop(
     self, delegate: httputil.HTTPServerConnectionDelegate
 ) -> None:
     try:
         while True:
             conn = HTTP1Connection(self.stream, False, self.params, self.context)
             request_delegate = delegate.start_request(self, conn)
             try:
                 ret = await conn.read_response(request_delegate)
             except (
                 iostream.StreamClosedError,
                 iostream.UnsatisfiableReadError,
                 asyncio.CancelledError,
             ):
                 return
             except _QuietException:
                 # This exception was already logged.
                 conn.close()
                 return
             except Exception:
                 gen_log.error("Uncaught exception", exc_info=True)
                 conn.close()
                 return
             if not ret:
                 return
             await asyncio.sleep(0)
     finally:
         delegate.on_close(self)
예제 #3
0
 def _server_request_loop(
     self, delegate: httputil.HTTPServerConnectionDelegate
 ) -> Generator[Any, Any, None]:
     try:
         while True:
             conn = HTTP1Connection(self.stream, False, self.params,
                                    self.context)
             request_delegate = delegate.start_request(self, conn)
             try:
                 ret = yield conn.read_response(request_delegate)
             except (iostream.StreamClosedError,
                     iostream.UnsatisfiableReadError):
                 return
             except _QuietException:
                 # This exception was already logged.
                 conn.close()
                 return
             except Exception:
                 gen_log.error("Uncaught exception", exc_info=True)
                 conn.close()
                 return
             if not ret:
                 return
             yield gen.moment
     finally:
         delegate.on_close(self)
예제 #4
0
 async def _server_request_loop(
     self, delegate: httputil.HTTPServerConnectionDelegate
 ) -> None:
     try:
         while True:  # 最终每一个连接都会在这里一直loop到死, 看出来了,返回为None, 也就是并不关注你返回的是什么东西
             conn = HTTP1Connection(self.stream, False, self.params, self.context)  # 封装连接对象
             request_delegate = delegate.start_request(self, conn)  # delegate就是HTTPServer -> 调用服务端的start_request -> routing._RoutingDelegate
             # 这里返回的delegate包含app、server_conn、request_conn,是一个_RoutingDelegate的实例
             try:
                 ret = await conn.read_response(request_delegate)
             except (
                 iostream.StreamClosedError,
                 iostream.UnsatisfiableReadError,
                 asyncio.CancelledError,
             ):
                 return
             except _QuietException:
                 # This exception was already logged.
                 conn.close()
                 return
             except Exception:
                 gen_log.error("Uncaught exception", exc_info=True)
                 conn.close()
                 return
             if not ret:
                 return
             await asyncio.sleep(0)
     finally:
         delegate.on_close(self)