当前位置: 首页>>代码示例>>Python>>正文


Python Website.shutdown方法代码示例

本文整理汇总了Python中aspen.website.Website.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python Website.shutdown方法的具体用法?Python Website.shutdown怎么用?Python Website.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aspen.website.Website的用法示例。


在下文中一共展示了Website.shutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from aspen.website import Website [as 别名]
# 或者: from aspen.website.Website import shutdown [as 别名]
def main(argv=None):
    """http://aspen.io/cli/
    """
    try:

        # Do imports.
        # ===========
        # These are in here so that if you Ctrl-C during an import, the
        # Keyboard Interupt is caught and ignored. Yes, that's how much I care.
        # No, I don't care enough to put aspen/__init__.py in here too.

        import os
        import logging
        import socket
        import sys
        import time
        from os.path import exists, join

        from aspen.server import restarter
        from aspen.website import Website

        
        log = logging.getLogger('aspen.cli')


        # Actual stuff.
        # =============

        if argv is None:
            argv = sys.argv[1:]
        website = Website(argv)
        try:
            if hasattr(socket, 'AF_UNIX'):
                if website.sockfam == socket.AF_UNIX:
                    if exists(website.address):
                        log.info("Removing stale socket.")
                        os.remove(website.address)
            if website.port is not None:
                welcome = "port %d" % website.port
            else:
                welcome = website.address
            log.info("Starting %s engine." % website.engine.name)
            log.warn("Greetings, program! Welcome to %s." % welcome)
            website.engine.init(website)
            if website.changes_kill:
                restarter.install(website)
            website.engine.start(website)
        finally:
            if hasattr(socket, 'AF_UNIX'):
                if website.sockfam == socket.AF_UNIX:
                    if exists(website.address):
                        os.remove(website.address)
            website.shutdown()
            website.engine.stop()
    except KeyboardInterrupt, SystemExit:
        pass
开发者ID:geekbuntu,项目名称:aspen,代码行数:58,代码来源:__init__.py


注:本文中的aspen.website.Website.shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。