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


Python Task.kill方法代码示例

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


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

示例1: __init__

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import kill [as 别名]
class alu_test:
    def __init__(self,
                 epc, enb, ue,
                 openair,
                 user, password,
                 log_subdir,
                 env,
                 enb_rru = "",
                 enb_rcc = ""):
        self.epc_machine      = epc
        self.enb_machine      = enb
        self.ue_machine       = ue
        self.openair_dir      = openair
        self.oai_user         = user
        self.oai_password     = password
        self.env              = env
        self.enb_rru_machine  = enb_rru
        self.enb_rcc_machine  = enb_rcc

        self.task_hss     = None
        self.task_enb     = None
        self.task_ue      = None
        self.task_rru_enb = None
        self.task_rcc_enb = None

        self.logdir = openair + '/cmake_targets/autotests/log/' + log_subdir
        quickshell('mkdir -p ' + self.logdir)

        #event object used to wait for several tasks at once
        self.event = threading.Event()

    ##########################################################################
    # finish
    ##########################################################################
    def finish(self):
        #brutally kill tasks still running
        #TODO: call 'wait', some processes may still be there as zombies
        if self.task_hss != None and self.task_hss.alive():
            self.task_hss.kill()
        if self.task_enb != None and self.task_enb.alive():
            self.task_enb.kill()
        if self.task_ue != None and self.task_ue.alive():
            self.task_ue.kill()
        if self.task_rru_enb != None and self.task_rru_enb.alive():
            self.task_rru_enb.kill()
        if self.task_rcc_enb != None and self.task_rcc_enb.alive():
            self.task_rcc_enb.kill()

    ##########################################################################
    # start_epc
    ##########################################################################
    def start_epc(self):
        #launch HSS, wait for prompt
        log("INFO: ALU test: run HSS")
        self.task_hss = Task("actions/alu_hss.bash",
                "alu_hss",
                self.epc_machine,
                self.oai_user,
                self.oai_password,
                self.env,
                self.logdir + "/alu_hss." + self.epc_machine,
                event=self.event)
        self.task_hss.waitlog('S6AS_SIM-> ')

        #then launch EPC, wait for connection on HSS side
        log("INFO: ALU test: run EPC")
        task_epc = Task("actions/alu_epc.bash",
                "ALU EPC",
                self.epc_machine,
                self.oai_user,
                self.oai_password,
                self.env,
                self.logdir + "/alu_epc." + self.epc_machine)
        ret = task_epc.wait()
        if ret != 0:
            log("ERROR: EPC start failure");
            raise TestFailed()
        self.task_hss.waitlog('Connected\n')

    ##########################################################################
    # stop_epc
    ##########################################################################
    def stop_epc(self):
        #stop EPC, wait for disconnection on HSS side
        log("INFO: ALU test: stop EPC")
        task_epc = Task("actions/alu_epc_stop.bash",
                "alu_epc_stop",
                self.epc_machine,
                self.oai_user,
                self.oai_password,
                self.env,
                self.logdir + "/alu_epc_stop." + self.epc_machine)
        ret = task_epc.wait()
        if ret != 0:
            log("ERROR: ALU test: ALU EPC stop failed")
            raise TestFailed()
        self.task_hss.waitlog('Disconnected\n')

        log("INFO: ALU test: stop HSS")
        self.task_hss.sendnow("exit\n")
#.........这里部分代码省略.........
开发者ID:ShibinMathew36,项目名称:OAI-step,代码行数:103,代码来源:alu_test.py

示例2: _do_traffic

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import kill [as 别名]
    def _do_traffic(self, name,
            server_code, server_machine, server_ip,
            client_code, client_machine,
            waitlog,
            server_logfile, client_logfile,
            udp_bandwidth=None):
        log("INFO: ALU test: run traffic: " + name)

        log("INFO: ALU test:     launch server")
        task_traffic_server = Task("actions/" + server_code + ".bash",
                server_logfile,
                server_machine,
                self.oai_user,
                self.oai_password,
                self.env,
                self.logdir + "/" + server_logfile + "." + server_machine,
                event=self.event)
        task_traffic_server.waitlog(waitlog)

        env = list(self.env)
        if udp_bandwidth != None:
            env.append("UDP_BANDWIDTH=" + udp_bandwidth)
        env.append("SERVER_IP=" + server_ip)

        log("INFO: ALU test:     launch client")
        task_traffic_client = Task("actions/" + client_code + ".bash",
                client_logfile,
                client_machine,
                self.oai_user,
                self.oai_password,
                env,
                self.logdir + "/" + client_logfile + "." + client_machine,
                event=self.event)
        log("INFO: ALU test:     wait for client to finish (or some error)")

        self.event.wait()
        log("DEBUG: event.wait() done")

        if (    (self.task_enb != None and not self.task_enb.alive()) or
                (self.task_rru_enb!=None and not self.task_rru_enb.alive()) or
                (self.task_rcc_enb!=None and not self.task_rcc_enb.alive()) or
                not self.task_hss.alive() or
                not self.task_ue.alive()):
            log("ERROR: unexpected task exited, test failed, kill all")
            if task_traffic_client.alive():
                task_traffic_client.kill()
            if (self.task_enb != None and self.task_enb.alive()):
                self.task_enb.kill()
            if (self.task_rru_enb != None and self.task_rru_enb.alive()):
                self.task_rru_enb.kill()
            if (self.task_rcc_enb != None and self.task_rcc_enb.alive()):
                self.task_rcc_enb.kill()
            if self.task_ue.alive():
                self.task_ue.kill()

        ret = task_traffic_client.wait()
        if ret != 0:
            log("ERROR: ALU test: downlink traffic failed")
            #not sure if we have to quit here or not
            #os._exit(1)

        #stop downlink server
        #log("INFO: ALU test:     stop server (kill ssh connection)")
        #task_traffic_server.kill()
        log("INFO: ALU test:     stop server (ctrl+z then kill -9 %1)")
        task_traffic_server.sendnow("%ckill -9 %%1 || true\n" % 26)
        log("INFO: ALU test:     wait for server to quit")
        task_traffic_server.wait()

        self.event.clear()

        if (    (self.task_enb != None and not self.task_enb.alive()) or
                (self.task_rru_enb!=None and not self.task_rru_enb.alive()) or
                (self.task_rcc_enb!=None and not self.task_rcc_enb.alive()) or
                not self.task_hss.alive() or
                not self.task_ue.alive()):
            log("ERROR: ALU test: eNB, HSS or UE task died")
            raise TestFailed()
开发者ID:ShibinMathew36,项目名称:OAI-step,代码行数:80,代码来源:alu_test.py


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