worker.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:sanic 作者: channelcat 项目源码 文件源码
def _check_alive(self):
        # If our parent changed then we shut down.
        pid = os.getpid()
        try:
            while self.alive:
                self.notify()

                req_count = sum(
                    self.servers[srv]["requests_count"] for srv in self.servers
                )
                if self.max_requests and req_count > self.max_requests:
                    self.alive = False
                    self.log.info("Max requests exceeded, shutting down: %s",
                                  self)
                elif pid == os.getpid() and self.ppid != os.getppid():
                    self.alive = False
                    self.log.info("Parent changed, shutting down: %s", self)
                else:
                    await asyncio.sleep(1.0, loop=self.loop)
        except (Exception, BaseException, GeneratorExit, KeyboardInterrupt):
            pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号