當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。