def on_shutdown(app):
"""
LOG_STDOUT
If logging stdout then StreamLogger needs a flush() method.
To recreate: enable LOG_STDOUT, run server, ^C interrupt:
Exception ignored in: <scrapy.utils.log.StreamLogger object at 0x7f...>
AttributeError: 'StreamLogger' object has no attribute 'flush'
twisted_log.PythonLoggingObserver
Observer is started in configure_logging, do we need to close it?
Close all opened sockets manually:
http://aiohttp.readthedocs.org/en/stable/web.html#graceful-shutdown
for ws in app['websockets']:
await ws.close(code=999, message='Server shutdown')
"""
logger.info('Scrapybox server shutting down')
# print(asyncio.Server.sockets, 'open sockets for asyncio')
# asyncio.Server.close()
# print(aiohttp.web.connections, 'open connections for aiohttp')
app.shutdown()
# aiohttp.web.finish_connections(5)
app.cleanup()
logger.info('Scrapybox server shutdown complete')
评论列表
文章目录