(self)
| 55 | |
| 56 | @asyncio.coroutine |
| 57 | def close(self): |
| 58 | if self.servers: |
| 59 | servers = self.servers |
| 60 | self.servers = None |
| 61 | |
| 62 | # stop accepting connections |
| 63 | for server, handler in servers.items(): |
| 64 | self.log.info("Stopping server: %s, connections: %s", |
| 65 | self.pid, len(handler.connections)) |
| 66 | server.close() |
| 67 | |
| 68 | # send on_shutdown event |
| 69 | yield from self.wsgi.shutdown() |
| 70 | |
| 71 | # stop alive connections |
| 72 | tasks = [ |
| 73 | handler.finish_connections( |
| 74 | timeout=self.cfg.graceful_timeout / 100 * 95) |
| 75 | for handler in servers.values()] |
| 76 | yield from asyncio.wait(tasks, loop=self.loop) |
| 77 | |
| 78 | # stop application |
| 79 | yield from self.wsgi.finish() |
| 80 | |
| 81 | @asyncio.coroutine |
| 82 | def _run(self): |
no test coverage detected