标签:try 区分 false gunicorn tempfile python ini 不同 支持
sync
eventlet
- Requires eventlet >= 0.9.7gevent
- Requires gevent >= 0.13tornado
- Requires tornado >= 0.2gthread
- Python 2 requires the futures package to be installedgaiohttp
- Requires Python 3.4 and aiohttp >= 0.21.5def run(self): if len(self.sockets) > 1: self.run_for_multiple(timeout) # 使用select else: self.run_for_one(timeout) # 如果只有一个监听socket,那么阻塞accept就行了
def handle_request(self, listener, req, client, addr): environ = {} resp = None try: self.cfg.pre_request(self, req) request_start = datetime.now() resp, environ = wsgi.create(req, client, addr, listener.getsockname(), self.cfg) # Force the connection closed until someone shows # a buffering proxy that supports Keep-Alive to # the backend. resp.force_close() self.nr += 1 if self.nr >= self.max_requests: self.log.info("Autorestarting worker after current request.") self.alive = False respiter = self.wsgi(environ, resp.start_response) try: if isinstance(respiter, environ[‘wsgi.file_wrapper‘]): resp.write_file(respiter) else: for item in respiter: resp.write(item) resp.close() request_time = datetime.now() - request_start self.log.access(resp, req, environ, request_time)
其中,调用到App的是下面这行代码
respiter = self.wsgi(environ, resp.start_response)
def notify(self): try: self.spinner = (self.spinner + 1) % 2 os.fchmod(self._tmp.fileno(), self.spinner) except AttributeError: # python < 2.6 self._tmp.truncate(0) os.write(self._tmp.fileno(), b"X")
def last_update(self): return os.fstat(self._tmp.fileno()).st_ctime
标签:try 区分 false gunicorn tempfile python ini 不同 支持
原文地址:http://www.cnblogs.com/xybaby/p/6297147.html