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


Python DaemonContext.terminate方法代码示例

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


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

示例1: _daemonize

# 需要导入模块: from daemon import DaemonContext [as 别名]
# 或者: from daemon.DaemonContext import terminate [as 别名]
    def _daemonize(self):
        from daemon import DaemonContext
        try:
            from daemon.pidfile import TimeoutPIDLockFile as PIDLockFile
        except:
            from daemon.pidlockfile import PIDLockFile

        pidlock = PIDLockFile('/var/run/fedmsg/%s.pid' % self.name)
        output = file('/var/log/fedmsg/%s.log' % self.name, 'a')
        daemon = DaemonContext(pidfile=pidlock, stdout=output, stderr=output)
        daemon.terminate = self._handle_signal

        with daemon:
            return self.run()
开发者ID:HousewifeHacker,项目名称:fedmsg,代码行数:16,代码来源:__init__.py

示例2: _daemonize

# 需要导入模块: from daemon import DaemonContext [as 别名]
# 或者: from daemon.DaemonContext import terminate [as 别名]
    def _daemonize(self, func, config):
        from daemon import DaemonContext

        try:
            from daemon.pidfile import TimeoutPIDLockFile as PIDLockFile
        except:
            from daemon.pidlockfile import PIDLockFile

        pidlock = PIDLockFile("/var/run/fedmsg/%s.pid" % self.name)
        output = file("/var/log/fedmsg/%s.log" % self.name, "a")
        daemon = DaemonContext(pidfile=pidlock, stdout=output, stderr=output)
        daemon.terminate = self._handle_signal

        with daemon:
            return func(**config)
开发者ID:silverrain,项目名称:fedmsg,代码行数:17,代码来源:__init__.py

示例3: _daemonize

# 需要导入模块: from daemon import DaemonContext [as 别名]
# 或者: from daemon.DaemonContext import terminate [as 别名]
    def _daemonize(self):
        import psutil
        from daemon import DaemonContext
        try:
            from daemon.pidfile import TimeoutPIDLockFile as PIDLockFile
        except:
            from daemon.pidlockfile import PIDLockFile

        pidlock = PIDLockFile('/var/run/fedmsg/%s.pid' % self.name)

        pid = pidlock.read_pid()
        if pid and not psutil.pid_exists(pid):
            self.log.warn("PID file exists but with no proc:  coup d'etat!")
            pidlock.break_lock()

        output = file('/var/log/fedmsg/%s.log' % self.name, 'a')
        daemon = DaemonContext(pidfile=pidlock, stdout=output, stderr=output)
        daemon.terminate = self._handle_signal

        with daemon:
            return self.run()
开发者ID:AdamWill,项目名称:fedmsg,代码行数:23,代码来源:__init__.py

示例4: daemon

# 需要导入模块: from daemon import DaemonContext [as 别名]
# 或者: from daemon.DaemonContext import terminate [as 别名]
def daemon():
    def die_in_a_fire(signum, stack):
        for thread in threads:
            thread.kill()

    import signal
    from daemon import DaemonContext
    try:
        from daemon.pidfile import TimeoutPIDLockFile as PIDLockFile
    except:
        from daemon.pidlockfile import PIDLockFile

    config = appconfig("config:" + find_config_file())

    #pidlock = PIDLockFile('/var/run/fedoracommunity/worker.pid')
    #output = file('/var/log/fedoracommunity/worker.log', 'a')
    pidlock = PIDLockFile(
        config.get('cache-worker.pidfile', '/tmp/fedoracommunity-worker.pid')
    )
    output = file(
        config.get('cache-worker.logfile', '/tmp/fedoracommunity-worker.log'),
        'a')

    daemon = DaemonContext(pidfile=pidlock, stdout=output, stderr=output)
    daemon.terminate = die_in_a_fire

    n = int(config.get('cache-worker.threads', '8'))
    with daemon:
        log.info("Creating %i threads" % n)
        for i in range(n):
            threads.append(Thread())

        for thread in threads:
            thread.start()

        # I used to do thread.join() here, but that makes it so the
        # signal_handler never gets fired.  Crazy python...
        while any([not thread.die for thread in threads]):
            time.sleep(2)
开发者ID:daviddavis,项目名称:fedora-packages,代码行数:41,代码来源:worker.py


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