當前位置: 首頁>>代碼示例>>Python>>正文


Python signal.NSIG屬性代碼示例

本文整理匯總了Python中signal.NSIG屬性的典型用法代碼示例。如果您正苦於以下問題:Python signal.NSIG屬性的具體用法?Python signal.NSIG怎麽用?Python signal.NSIG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在signal的用法示例。


在下文中一共展示了signal.NSIG屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_add_signal_handler_coroutine_error

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def test_add_signal_handler_coroutine_error(self, m_signal):
        m_signal.NSIG = signal.NSIG

        @asyncio.coroutine
        def simple_coroutine():
            yield from []

        # callback must not be a coroutine function
        coro_func = simple_coroutine
        coro_obj = coro_func()
        self.addCleanup(coro_obj.close)
        for func in (coro_func, coro_obj):
            self.assertRaisesRegex(
                TypeError, 'coroutines cannot be used with add_signal_handler',
                self.loop.add_signal_handler,
                signal.SIGINT, func) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:18,代碼來源:test_unix_events.py

示例2: test_add_signal_handler_install_error

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def test_add_signal_handler_install_error(self, m_signal):
        m_signal.NSIG = signal.NSIG

        def set_wakeup_fd(fd):
            if fd == -1:
                raise ValueError()
        m_signal.set_wakeup_fd = set_wakeup_fd

        class Err(OSError):
            errno = errno.EFAULT
        m_signal.signal.side_effect = Err

        self.assertRaises(
            Err,
            self.loop.add_signal_handler,
            signal.SIGINT, lambda: True) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:18,代碼來源:test_unix_events.py

示例3: _serve

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def _serve(self):
        if hasattr(signal, 'pthread_sigmask'):
            signal.pthread_sigmask(signal.SIG_BLOCK, range(1, signal.NSIG))
        while 1:
            try:
                with self._listener.accept() as conn:
                    msg = conn.recv()
                    if msg is None:
                        break
                    key, destination_pid = msg
                    send, close = self._cache.pop(key)
                    try:
                        send(conn, destination_pid)
                    finally:
                        close()
            except:
                if not util.is_exiting():
                    sys.excepthook(*sys.exc_info()) 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:20,代碼來源:resource_sharer.py

示例4: _reset_signal_handlers

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def _reset_signal_handlers():
    for s in _signals_to_reset:
        # On FreeBSD, the numerical value of SIGRT* is larger than NSIG
        # from signal.h (which is a bug in my opinion). Do not change
        # action for these signals. This prevents a ValueError raised
        # in the signal module.
        if s < signal.NSIG:
            signal.signal(s, signal.SIG_DFL) 
開發者ID:jgehrcke,項目名稱:gipc,代碼行數:10,代碼來源:gipc.py

示例5: __init__

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def __init__(self):
        import signal
        self.signal = signal
        self.signals = list(range(1, signal.NSIG))
        # SIGKILL and SIGSTOP signals cannot be ignored nor catched
        for signame in ('SIGKILL', 'SIGSTOP'):
            try:
                signum = getattr(signal, signame)
            except AttributeError:
                continue
            self.signals.remove(signum)
        self.handlers = {} 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:14,代碼來源:__init__.py

示例6: test_module_constants

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def test_module_constants(self):
        self.assertEqual(signal.NSIG, 23)
        self.assertEqual(signal.SIGABRT, 22)
        self.assertEqual(signal.SIGBREAK, 21)
        self.assertEqual(signal.SIGFPE, 8)
        self.assertEqual(signal.SIGILL, 4)
        self.assertEqual(signal.SIGINT, 2)
        self.assertEqual(signal.SIGSEGV, 11)
        self.assertEqual(signal.SIGTERM, 15)
        self.assertEqual(signal.SIG_DFL, 0)
        self.assertEqual(signal.SIG_IGN, 1) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:test_signal.py

示例7: _signal_number_to_name

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def _signal_number_to_name(signum):
    """
    Return a name for the signal number, or None if no name can be found.

    >>> _signal_number_to_name(signal.SIGINT)
    'SIGINT'
    >>> _signal_number_to_name(signal.NSIG + 1)
    """

    names = _signums.get(signum, [])
    if not names:
        return None
    return "/".join(names) 
開發者ID:abusesa,項目名稱:abusehelper,代碼行數:15,代碼來源:startup.py

示例8: strsignal

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def strsignal(signo):
    # in large part from http://code.activestate.com/recipes/578899-strsignal/
    libc = ctypes.CDLL(ctypes.util.find_library("c"))
    strsignal_c = ctypes.CFUNCTYPE(ctypes.c_char_p, ctypes.c_int)(("strsignal", libc), ((1,),))
    NSIG = signal.NSIG

    # The behavior of the C library strsignal() is unspecified if
    # called with an out-of-range argument.  Range-check on entry
    # _and_ NULL-check on exit.
    if 0 <= signo < NSIG:
        s = strsignal_c(signo)
        if s:
            return s.decode("utf-8")
    return "Unknown signal %d" % signo 
開發者ID:DMOJ,項目名稱:judge-server,代碼行數:16,代碼來源:os_ext.py

示例9: _resetSignalDisposition

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def _resetSignalDisposition(self):
        # The Python interpreter ignores some signals, and our child
        # process will inherit that behaviour. To have a child process
        # that responds to signals normally, we need to reset our
        # child process's signal handling (just) after we fork and
        # before we execvpe.
        for signalnum in xrange(1, signal.NSIG):
            if signal.getsignal(signalnum) == signal.SIG_IGN:
                # Reset signal handling to the default
                signal.signal(signalnum, signal.SIG_DFL) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:12,代碼來源:process.py

示例10: test_getSignalNameWithLocalSignal

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def test_getSignalNameWithLocalSignal(self):
        """
        If there are signals in the signal module which aren't in the SSH RFC,
        we map their name to [signal name]@[platform].
        """
        signal.SIGTwistedTest = signal.NSIG + 1 # value can't exist normally
        # Force reinitialization of signals
        self.pp._signalValuesToNames = None
        self.assertEqual(self.pp._getSignalName(signal.SIGTwistedTest),
                          'SIGTwistedTest@' + sys.platform) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:12,代碼來源:test_session.py

示例11: __init__

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def __init__(self, loop, signalnum, ref=True, priority=None):
        if signalnum < 1 or signalnum >= signalmodule.NSIG:
            raise ValueError('illegal signal number: %r' % signalnum)
        # still possible to crash on one of libev's asserts:
        # 1) "libev: ev_signal_start called with illegal signal number"
        #    EV_NSIG might be different from signal.NSIG on some platforms
        # 2) "libev: a signal must not be attached to two different loops"
        #    we probably could check that in LIBEV_EMBED mode, but not in general
        watcher.__init__(self, loop, ref=ref, priority=priority, args=(signalnum, )) 
開發者ID:leancloud,項目名稱:satori,代碼行數:11,代碼來源:corecffi.py

示例12: _check_signal

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def _check_signal(self, sig):
        """Internal helper to validate a signal.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        """
        if not isinstance(sig, int):
            raise TypeError('sig must be an int, not {!r}'.format(sig))

        if not (1 <= sig < signal.NSIG):
            raise ValueError(
                'sig {} out of range(1, {})'.format(sig, signal.NSIG)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:14,代碼來源:unix_events.py

示例13: test_check_signal

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def test_check_signal(self):
        self.assertRaises(
            TypeError, self.loop._check_signal, '1')
        self.assertRaises(
            ValueError, self.loop._check_signal, signal.NSIG + 1) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:7,代碼來源:test_unix_events.py

示例14: test_handle_signal_no_handler

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def test_handle_signal_no_handler(self):
        self.loop._handle_signal(signal.NSIG + 1) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:4,代碼來源:test_unix_events.py

示例15: test_handle_signal_cancelled_handler

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import NSIG [as 別名]
def test_handle_signal_cancelled_handler(self):
        h = asyncio.Handle(mock.Mock(), (),
                           loop=mock.Mock())
        h.cancel()
        self.loop._signal_handlers[signal.NSIG + 1] = h
        self.loop.remove_signal_handler = mock.Mock()
        self.loop._handle_signal(signal.NSIG + 1)
        self.loop.remove_signal_handler.assert_called_with(signal.NSIG + 1) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:10,代碼來源:test_unix_events.py


注:本文中的signal.NSIG屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。