当前位置: 首页>>代码示例>>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;未经允许,请勿转载。