server.py 文件源码

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

项目:scrapybox 作者: stav 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号