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


Python Common.kill方法代码示例

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


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

示例1: _check

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import kill [as 别名]
    def _check(self):

        # This will kill the TACTIC process 
        # This is very harsh and should be used sparingly if at all
        use_restart = Config.get_value("services", "use_periodic_restart")
        if use_restart in [True, 'true']:
            if self.num_checks and self.num_checks % self.kill_interval == 0:
                # read pid file
                log_dir = "%s/log" % Environment.get_tmp_dir()
                file = open("%s/pid.%s" % (log_dir,self.port), "r")
                pid = file.read()
                file.close()
                Common.kill(pid)

                #self.run()
                self.num_checks += 1
                return


        self.num_checks += 1

        start = time.clock()
        try:
            response = self.check()
        except IOError, e:

            pid = self._get_pid() 
            if pid:
                Common.kill(pid)
开发者ID:mincau,项目名称:TACTIC,代码行数:31,代码来源:monitor.py

示例2: final_kill

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import kill [as 别名]
    def final_kill(self):
        '''Kill the startup, startup_queue, watch_folder processes. This is used primarily in Windows Service.
           Linux service should have actively killed the processes already'''
        log_dir = "%s/log" % Environment.get_tmp_dir()
        files = os.listdir(log_dir)
        ports = []
        watch_folders = []
        queues = []

        for filename in files:
            base, ext = os.path.splitext(filename)
            if base == 'pid':
                ports.append(ext[1:])
            elif base == 'watch_folder':
                watch_folders.append(ext[1:])
            elif base == 'startup_queue':
                queues.append(ext[1:])

    
        for port in ports:
            try:
                file_name = "%s/pid.%s" % (log_dir,port)
                file = open(file_name, "r")
                pid = file.readline().strip()
                file.close()
                Common.kill(pid)
            except IOError, e:
                continue
开发者ID:mincau,项目名称:TACTIC,代码行数:30,代码来源:monitor.py

示例3: execute

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import kill [as 别名]
 def execute(my):
     import cherrypy
     print
     print "Stopping TACTIC ..."
     print 
     print " ... stopping Schduler"
     scheduler = Scheduler.get()
     scheduler.stop()
     print " ... stopping Cherrypy"
     cherrypy.engine.stop()
     cherrypy.engine.exit()
     print " ... closing DB connections"
     DbContainer.close_all_global_connections()
     print " ... kill current process"
     Common.kill()
     print "Done."
开发者ID:0-T-0,项目名称:TACTIC,代码行数:18,代码来源:cache_startup.py

示例4: execute

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import kill [as 别名]
            def execute(self):
                # wait until KillThread is premitted
                while GlobalContainer.get("KillThreadCmd:allow") == "false":
                    print "Kill locked ... waiting 5 seconds"
                    time.sleep(5)
                    continue

                import cherrypy
                print
                print "Stopping TACTIC ..."
                print 
                print " ... stopping Schduler"
                scheduler = Scheduler.get()
                scheduler.stop()
                print " ... stopping Cherrypy"
                cherrypy.engine.stop()
                cherrypy.engine.exit()
                print " ... closing DB connections"
                DbContainer.close_all_global_connections()
                print " ... kill current process"
                Common.kill()
                print "Done."
开发者ID:mincau,项目名称:TACTIC,代码行数:24,代码来源:cache_startup.py

示例5: _check

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import kill [as 别名]
    def _check(my):

        # This will kill the TACTIC process 
        # This is very harsh and should be used sparingly if at all
        use_restart = Config.get_value("services", "use_periodic_restart")
        if use_restart in [True, 'true']:
            if my.num_checks and my.num_checks % my.kill_interval == 0:
                # read pid file
                log_dir = "%s/log" % Environment.get_tmp_dir()
                file = open("%s/pid.%s" % (log_dir,my.port), "r")
                pid = file.read()
                file.close()
                print "Killing process: ", pid
                Common.kill(pid)

                #my.run()
                my.num_checks += 1
                return



        my.num_checks += 1

        start = time.clock()
        try:
            response = my.check()
        except IOError, e:
            print "Tactic IOError: ", str(e)

            # Kill if unresponsive ... (only on linux)
            log_dir = "%s/log" % Environment.get_tmp_dir()
            file = open("%s/pid.%s" % (log_dir,my.port), "r")
            pid = file.read()
            file.close()
            print "Killing process: ", pid
            Common.kill(pid) 
开发者ID:funic,项目名称:TACTIC,代码行数:38,代码来源:monitor.py

示例6: open

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import kill [as 别名]
        self.num_checks += 1

        start = time.clock()
        try:
            response = self.check()
        except IOError, e:

            pid = self._get_pid() 
            if pid:
                Common.kill(pid)
        else:
            if response and response != "OK":
                #self.end = True
                pid = self._get_pid() 
                if pid:
                    Common.kill(pid)
                return

        '''
        # check the time it took to respond
        end = time.clock()
        interval = end - start

        # if greater than 5 second, kill the process and restart
        if interval > 5:
            # read pid file
            log_dir = "%s/log" % Environment.get_tmp_dir()
            file = open("%s/pid.%s" % (log_dir,self.port), "r")
            pid = file.read()
            file.close()
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:monitor.py

示例7: _run

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import kill [as 别名]
    def _run(self):

        task = self.kwargs.get("task")
        paths = task.get_paths()
        count = 0
        restart = False

        while True:
            
            if not paths:
                time.sleep(1)
                continue
            
            path = paths.pop(0)
            checkin_path = "%s.checkin" % path
            lock_path = "%s.lock" % path
            error_path = "%s.error" % path

            if not os.path.exists(path):
                continue
            if not os.path.exists(checkin_path):
                #print "Action Thread SKIP: no checkin path [%s]" % checkin_path
                continue
            else:
                # Exit if another process is also checking this file in.                
                f = open(checkin_path, "r")
                pid = f.readline()
                f.close()
                if pid != str(os.getpid()):
                    continue

            try:

                kwargs = {
                    "project_code": task.project_code,
                    "search_type": task.search_type,
                    "base_dir": task.base_dir,
                    "process": task.process,
                    "script_path": task.script_path,
                    "path": path
                }

                handler = task.get("handler")
                if handler:
                    cmd = Common.create_from_class_path(handler, [], kwargs)
                else:
                    # create a "custom" command that will act on the file
                    cmd = CheckinCmd(**kwargs)

                #print "Process [%s] checking in [%s]" % (os.getpid(), path)
                cmd.execute()

                # TEST
                #time.sleep(1)
                #if os.path.exists(path):
                #    os.unlink(path)

                count += 1
                if count == 20:
                    restart = True
                    task.set_clean(True)
                    break


            except Exception as e:
                print "Error: ", e
                f = open(error_path,"w")
                f.write(str(e))
                f.close()
                #raise

            finally:

                task.set_clean(True)
                if os.path.exists(checkin_path):
                    os.unlink(checkin_path)
                if os.path.exists(lock_path):
                    os.unlink(lock_path)
                task.set_clean(False)
                
                if restart:
                    task.set_clean(True)



        # restart every 20 check-ins
        if restart:
            for path in paths:
                checkin_path = "%s.checkin" % path
                lock_path = "%s.lock" % path
                if os.path.exists(checkin_path):
                    os.unlink(checkin_path)
                if os.path.exists(lock_path):
                    os.unlink(lock_path)
            # this exaggerates the effect of not pausing check thread for cleaning
            #time.sleep(10)
            Common.kill()
开发者ID:mincau,项目名称:TACTIC,代码行数:99,代码来源:watch_drop_folder.py


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