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


Python signal.SIGKILL属性代码示例

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


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

示例1: after_scenario

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def after_scenario(context, scenario):
    """Cleans up after each scenario completes."""
    if hasattr(context, "cli") and context.cli and not context.exit_sent:
        # Quit nicely.
        if not context.atprompt:
            dbname = context.currentdb
            context.cli.expect_exact("{0}> ".format(dbname), timeout=15)
        context.cli.sendcontrol("c")
        context.cli.sendcontrol("d")
        try:
            context.cli.expect_exact(pexpect.EOF, timeout=15)
        except pexpect.TIMEOUT:
            print("--- after_scenario {}: kill cli".format(scenario.name))
            context.cli.kill(signal.SIGKILL)
    if hasattr(context, "tmpfile_sql_help") and context.tmpfile_sql_help:
        context.tmpfile_sql_help.close()
        context.tmpfile_sql_help = None


# # TODO: uncomment to debug a failure
# def after_step(context, step):
#     if step.status == "failed":
#         import pdb; pdb.set_trace() 
开发者ID:dbcli,项目名称:pgcli,代码行数:25,代码来源:environment.py

示例2: stopChild

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def stopChild(self):
        logging.debug("Terminate child...")
        if self.p is not None:
            self.p.terminate()

        logging.debug("Kill server: " + str(self.serverPid))

        if self.serverPid is not None:
            try:
                os.kill(self.serverPid, signal.SIGTERM)
                os.kill(self.serverPid, signal.SIGKILL)
            except Exception as e:
                logging.error("Kill exception, but child should be alive: " + str(e))

        self.p = None
        self.serverPid = None

    ######################## 
开发者ID:dobin,项目名称:ffw,代码行数:20,代码来源:verifier.py

示例3: do_GET

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def do_GET(self):
        client_address = self.client_address[0]
        logger.info('Serving transcoded media file to {} ...'.format(
            client_address))

        self.send_head()
        path = self.translate_path(self.path)
        command = VLCEncoderSettings.command(path)
        logger.info('Launching {}'.format(command))

        try:
            with open(os.devnull, 'w') as dev_null:
                encoder_process = subprocess.Popen(
                    command, stdout=subprocess.PIPE, stderr=dev_null)
                shutil.copyfileobj(encoder_process.stdout, self.wfile)
        except:
            logger.info('Connection from {} closed.'.format(client_address))
            logger.debug(traceback.format_exc())
        finally:
            pid = encoder_process.pid
            logger.info('Terminating process {}'.format(pid))
            try:
                os.kill(pid, signal.SIGKILL)
            except:
                pass 
开发者ID:masmu,项目名称:pulseaudio-dlna,代码行数:27,代码来源:chromecast-beam.py

示例4: PosixShutdown

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def PosixShutdown():
  """Kills a posix process with os.kill."""
  dev_process = GlobalProcess()
  children = dev_process.Children()
  for term_signal in (signal.SIGTERM, signal.SIGKILL):
    for child in children:
      if child.process is None:
        continue
      if child.process.returncode is not None:
        continue
      pid = child.process.pid
      try:
        logging.debug('posix kill %d with signal %d', pid, term_signal)
        os.kill(pid, term_signal)
      except OSError, err:
        logging.error('Error encountered sending pid %d signal %d:%s\n',
                      pid, term_signal, err)
        break

    time.sleep(0.2) 
开发者ID:elsigh,项目名称:browserscope,代码行数:22,代码来源:dev_appserver_multiprocess.py

示例5: stop

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def stop(self, graceful=True):
        """\
        Stop workers

        :attr graceful: boolean, If True (the default) workers will be
        killed gracefully  (ie. trying to wait for the current connection)
        """

        if self.reexec_pid == 0 and self.master_pid == 0:
            for l in self.LISTENERS:
                l.close()

        self.LISTENERS = []
        sig = signal.SIGTERM
        if not graceful:
            sig = signal.SIGQUIT
        limit = time.time() + self.cfg.graceful_timeout
        # instruct the workers to exit
        self.kill_workers(sig)
        # wait until the graceful timeout
        while self.WORKERS and time.time() < limit:
            time.sleep(0.1)

        self.kill_workers(signal.SIGKILL) 
开发者ID:jpush,项目名称:jbox,代码行数:26,代码来源:arbiter.py

示例6: murder_workers

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def murder_workers(self):
        """\
        Kill unused/idle workers
        """
        if not self.timeout:
            return
        workers = list(self.WORKERS.items())
        for (pid, worker) in workers:
            try:
                if time.time() - worker.tmp.last_update() <= self.timeout:
                    continue
            except (OSError, ValueError):
                continue

            if not worker.aborted:
                self.log.critical("WORKER TIMEOUT (pid:%s)", pid)
                worker.aborted = True
                self.kill_worker(pid, signal.SIGABRT)
            else:
                self.kill_worker(pid, signal.SIGKILL) 
开发者ID:jpush,项目名称:jbox,代码行数:22,代码来源:arbiter.py

示例7: __init__

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def __init__(self, rr_endpoint, ann_endpoint):
        super(ZMQWorker,self).__init__()
        
        # Upstream endpoints
        self.rr_endpoint = rr_endpoint
        self.ann_endpoint = ann_endpoint
                
        # Downstream endpoints
        self.task_endpoint = self.make_internal_endpoint()
        self.result_endpoint = self.make_internal_endpoint()
        
        self.master_id = None
        self.identified = False
        
        # The task currently being processed
        self.pending_task = None
        
        # Executor process
        
        self.shutdown_timeout = 5.0 # Five second wait between shutdown message and SIGINT and SIGINT and SIGKILL
        self.executor_process = None 
开发者ID:westpa,项目名称:westpa,代码行数:23,代码来源:worker.py

示例8: terminate_process

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def terminate_process():
    if m2ee:
        logging.info("stopping app...")
        if not m2ee.stop():
            if not m2ee.terminate():
                m2ee.kill()
    try:
        this_process = os.getpgid(0)
        logging.debug(
            "Terminating process group with pgid=%s", format(this_process)
        )
        os.killpg(this_process, signal.SIGTERM)
        time.sleep(3)
        os.killpg(this_process, signal.SIGKILL)
    except OSError:
        logging.exception("Failed to terminate all child processes") 
开发者ID:mendix,项目名称:cf-mendix-buildpack,代码行数:18,代码来源:start.py

示例9: kill_process

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def kill_process(pid, sig=None):
    """Try to send signal to given process."""
    if sig is None:
        sig = signal.SIGKILL  # set default lazily, otherwise importing fails on Windows
    try:
        os.kill(pid, sig)
    except OSError as e:
        if e.errno == errno.ESRCH:
            # process itself returned and exited before killing
            logging.debug(
                "Failure %s while killing process %s with signal %s: %s",
                e.errno,
                pid,
                sig,
                e.strerror,
            )
        else:
            logging.warning(
                "Failure %s while killing process %s with signal %s: %s",
                e.errno,
                pid,
                sig,
                e.strerror,
            ) 
开发者ID:sosy-lab,项目名称:benchexec,代码行数:26,代码来源:util.py

示例10: do_cancel

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def do_cancel(self, sig=signal.SIGKILL):
        """
        Kill process during migration.

        :param sig: The signal to send
        :raise: test.error when kill fails
        """
        def _get_pid():
            cmd = "ps aux |grep 'virsh .*migrate' |grep -v grep |awk '{print $2}'"
            pid = process.run(cmd, shell=True).stdout_text
            return pid

        pid = utils_misc.wait_for(_get_pid, 30)
        if utils_misc.safe_kill(pid, sig):
            logging.info("Succeed to cancel migration: [%s].", pid.strip())
        else:
            raise exceptions.TestError("Fail to cancel migration: [%s]"
                                       % pid.strip()) 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:20,代码来源:migration.py

示例11: test_wait_timeout_0

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def test_wait_timeout_0(self):
        sproc = get_test_subprocess()
        p = psutil.Process(sproc.pid)
        self.assertRaises(psutil.TimeoutExpired, p.wait, 0)
        p.kill()
        stop_at = time.time() + 2
        while True:
            try:
                code = p.wait(0)
            except psutil.TimeoutExpired:
                if time.time() >= stop_at:
                    raise
            else:
                break
        if POSIX:
            self.assertEqual(code, -signal.SIGKILL)
        else:
            self.assertEqual(code, signal.SIGTERM)
        self.assertFalse(p.is_running()) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:21,代码来源:test_process.py

示例12: kill_on_exception

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def kill_on_exception(logname):
    """decorator to ensure functions will kill ryu when an unhandled exception
    occurs"""
    def _koe(func):
        @wraps(func)
        def __koe(*args, **kwargs):
            try:
                func(*args, **kwargs)
            except:
                logging.getLogger(logname).exception(
                    "Unhandled exception, killing RYU")
                logging.shutdown()
                os.kill(os.getpid(), signal.SIGKILL)
        return __koe
    return _koe 
开发者ID:sdn-ixp,项目名称:iSDX,代码行数:17,代码来源:faucet_util.py

示例13: detach

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def detach(self):
        """
        Stop listening for log messages.

        After this is called, no additional messages will be added to the
        queue.
        """
        if self.listening:
            # We have to kill the process explicitly with SIGKILL,
            # terminate() function does not work here.
            for process in self.processes:
                os.kill(process.pid, signal.SIGKILL)

            self.processes = []
            self.listening = False 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:17,代码来源:log_provider.py

示例14: check_kill_process

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def check_kill_process(pstring):
        # Static method for killing given processes
        for line in os.popen("ps ax | grep " + pstring + " | grep -v grep"):
            fields = line.split()
            pid = fields[0]
            if pid:
                os.kill(int(pid), signal.SIGKILL) 
开发者ID:ShahriyarR,项目名称:MySQL-AutoXtraBackup,代码行数:9,代码来源:take_backup.py

示例15: kill

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGKILL [as 别名]
def kill(self):
            """Kill the process with SIGKILL
            """
            self.send_signal(signal.SIGKILL) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:6,代码来源:subprocess.py


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