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


Python signal.SIGUSR2属性代码示例

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


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

示例1: test_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def test_signals(self):
        signalled_all.acquire()
        self.spawnSignallingThread()
        signalled_all.acquire()
        # the signals that we asked the kernel to send
        # will come back, but we don't know when.
        # (it might even be after the thread exits
        # and might be out of order.)  If we haven't seen
        # the signals yet, send yet another signal and
        # wait for it return.
        if signal_blackboard[signal.SIGUSR1]['tripped'] == 0 \
           or signal_blackboard[signal.SIGUSR2]['tripped'] == 0:
            try:
                signal.alarm(1)
                signal.pause()
            finally:
                signal.alarm(0)

        self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped'], 1)
        self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped_by'],
                           thread.get_ident())
        self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped'], 1)
        self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped_by'],
                           thread.get_ident())
        signalled_all.release() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:test_threadsignals.py

示例2: test_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def test_signals(self):
        signalled_all.acquire()
        self.spawnSignallingThread()
        signalled_all.acquire()
        # the signals that we asked the kernel to send
        # will come back, but we don't know when.
        # (it might even be after the thread exits
        # and might be out of order.)  If we haven't seen
        # the signals yet, send yet another signal and
        # wait for it return.
        if signal_blackboard[signal.SIGUSR1]['tripped'] == 0 \
           or signal_blackboard[signal.SIGUSR2]['tripped'] == 0:
            signal.alarm(1)
            signal.pause()
            signal.alarm(0)

        self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped'], 1)
        self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped_by'],
                           thread.get_ident())
        self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped'], 1)
        self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped_by'],
                           thread.get_ident())
        signalled_all.release() 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:25,代码来源:test_threadsignals.py

示例3: shutdown

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def shutdown(self):

        if self.launched:
            self.semaphore.acquire()

            self.child.kill(signal.SIGUSR2)

            # wait for rtkrcv to shutdown
            try:
                self.child.wait()
            except pexpect.ExceptionPexpect:
                print("Already dead!!")

            if self.child.isalive():
                r = -1
            else:
                r = 1

            self.semaphore.release()
            self.launched = False

            return r

        # already shut down
        return 2 
开发者ID:Stefal,项目名称:rtkbase,代码行数:27,代码来源:RtkController.py

示例4: test_log

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def test_log(self):
        """Logging tests"""

        # Not much to test here but exercise the code nonetheless
        # for regression/coverage.

        log = Log(verbose=False, prefix='test')

        log.debug("Invisible debug.")

        try:
            raise ValueError("Test exception")
        except ValueError:
            log.exception("Test exception with message")

        for num in range(1, 5):
            log.debug("Debug")
            log.info("Info")
            log.warning("Warning")
            log.error("Error")
            log.critical("Crtitical")
            os.kill(os.getpid(),
                    signal.SIGUSR1 if (num % 2) != 0 else signal.SIGUSR2) 
开发者ID:perfsonar,项目名称:pscheduler,代码行数:25,代码来源:log_test.py

示例5: MockTracer

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def MockTracer(self):
        """
        Construct a mock tracer.
        """
        tracer = MagicMock()
        tracer.address = self.tracer_host, self.tracer_port
        tracer.pause_signal = signal.SIGUSR2
        tracer.retry_attempts = 1
        tracer.local = 0, 0
        tracer.uuid = 'mock'
        tracer.watchlist = {}
        tracer.curframe = sys._getframe()
        tracer.stack = [(sys._getframe(), 1)] * 3
        tracer.skip_fn = lambda _: False
        tracer.cmd_manager = self.cmd_manager
        return tracer 
开发者ID:quantopian,项目名称:qdb,代码行数:18,代码来源:test_cmd_manager.py

示例6: __init__

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def __init__(self):
        self.signals = {
            'reload_conf_pending': False,
            'interrupted': False,
            'open_backdoor': False,
            'orig': {
                signal.SIGINT: None,
                signal.SIGTERM: None,
            }
        }
        try:
            self.signals['orig'].update({
                signal.SIGUSR1: None,
                signal.SIGUSR2: None,
            })
        except AttributeError:
            # Unavailable on Windows
            pass 
开发者ID:kibitzr,项目名称:kibitzr,代码行数:20,代码来源:app.py

示例7: test_register_signal_handler

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def test_register_signal_handler(
        self,
        patch_config,
        patch_db_connections,
        patch_restarter,
        patch_signal,
        patch_running,
        patch_producer,
        patch_exit,
    ):
        patch_running.return_value = False
        replication_stream = self._init_and_run_batch()
        # ZKLock also calls patch_signal, so we have to work around it
        assert [
            mock.call(signal.SIGINT, replication_stream._handle_shutdown_signal),
            mock.call(signal.SIGTERM, replication_stream._handle_shutdown_signal),
            mock.call(signal.SIGUSR2, replication_stream._handle_profiler_signal),
        ] in patch_signal.call_args_list 
开发者ID:Yelp,项目名称:mysql_streamer,代码行数:20,代码来源:parse_replication_stream_internal_test.py

示例8: set_up_editor_wait

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def set_up_editor_wait(quteproc, tmpdir, text, editor_pid_watcher):
    """Set up editor.command to a small python script inserting a text."""
    assert not utils.is_windows
    pidfile = tmpdir / 'editor_pid'
    script = tmpdir / 'script.py'
    script.write(textwrap.dedent("""
        import os
        import sys
        import time
        import signal

        def handle(sig, _frame):
            filename = sys.argv[1]
            old_mtime = new_mtime = os.stat(filename).st_mtime
            while old_mtime == new_mtime:
                time.sleep(0.1)
                with open(filename, 'w', encoding='utf-8') as f:
                    f.write({text!r})
                new_mtime = os.stat(filename).st_mtime
            if sig == signal.SIGUSR1:
                sys.exit(0)

        signal.signal(signal.SIGUSR1, handle)
        signal.signal(signal.SIGUSR2, handle)

        with open(r'{pidfile}', 'w') as f:
            f.write(str(os.getpid()))

        time.sleep(100)
    """.format(pidfile=pidfile, text=text)))
    editor = json.dumps([sys.executable, str(script), '{}'])
    quteproc.set_setting('editor.command', editor) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:34,代码来源:test_editor_bdd.py

示例9: save_editor_wait

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def save_editor_wait(tmpdir):
    """Trigger the waiting editor to write without exiting."""
    pidfile = tmpdir / 'editor_pid'
    # give the "editor" process time to write its pid
    for _ in range(10):
        if pidfile.check():
            break
        time.sleep(1)
    pid = int(pidfile.read())
    # windows has no SIGUSR2, but we don't run this on windows anyways
    # for posix, there IS a member so we need to ignore useless-suppression
    # pylint: disable=no-member,useless-suppression
    os.kill(pid, signal.SIGUSR2) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:15,代码来源:test_editor_bdd.py

示例10: sigusr_handler

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def sigusr_handler(_signo, _stack_frame):
            if _signo == signal.SIGUSR1:
                emit(jvm={"errors": 1.0})
            elif _signo == signal.SIGUSR2:
                emit(jvm={"ooms": 1.0})
            else:
                # Should not happen
                pass
            m2ee.stop()
            sys.exit(1) 
开发者ID:mendix,项目名称:cf-mendix-buildpack,代码行数:12,代码来源:start.py

示例11: registerSignals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def registerSignals(for_usr1, for_usr2, for_alrm):
    usr1 = signal.signal(signal.SIGUSR1, for_usr1)
    usr2 = signal.signal(signal.SIGUSR2, for_usr2)
    alrm = signal.signal(signal.SIGALRM, for_alrm)
    return usr1, usr2, alrm


# The signal handler. Just note that the signal occurred and
# from who. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_threadsignals.py

示例12: send_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def send_signals():
    os.kill(process_pid, signal.SIGUSR1)
    os.kill(process_pid, signal.SIGUSR2)
    signalled_all.release() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_threadsignals.py

示例13: test_main

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def test_main():
    global signal_blackboard

    signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 },
                          signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 },
                          signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } }

    oldsigs = registerSignals(handle_signals, handle_signals, handle_signals)
    try:
        run_unittest(ThreadSignals)
    finally:
        registerSignals(*oldsigs) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_threadsignals.py

示例14: configure_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def configure_signals():  # pragma: no cover
    '''
    Configure borgmatic's signal handlers to pass relevant signals through to any child processes
    like Borg. Note that SIGINT gets passed through even without these changes.
    '''
    for signal_number in (signal.SIGHUP, signal.SIGTERM, signal.SIGUSR1, signal.SIGUSR2):
        signal.signal(signal_number, _handle_signal) 
开发者ID:witten,项目名称:borgmatic,代码行数:9,代码来源:signals.py

示例15: stop

# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGUSR2 [as 别名]
def stop(self):
        # terminate the stream

        if self.started:
            self.child.kill(signal.SIGUSR2)
            try:
                self.child.wait()
            except pexpect.ExceptionPexpect:
                print("Str2str already down")

            self.started = False
            return 1

        # str2str already stopped
        return 2 
开发者ID:Stefal,项目名称:rtkbase,代码行数:17,代码来源:Str2StrController.py


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