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


Python signal.siginterrupt方法代码示例

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


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

示例1: installHandler

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def installHandler(fd):
    """
    Install a signal handler which will write a byte to C{fd} when
    I{SIGCHLD} is received.

    This is implemented by installing a SIGCHLD handler that does nothing,
    setting the I{SIGCHLD} handler as not allowed to interrupt system calls,
    and using L{signal.set_wakeup_fd} to do the actual writing.

    @param fd: The file descriptor to which to write when I{SIGCHLD} is
        received.
    @type fd: C{int}
    """
    if fd == -1:
        signal.signal(signal.SIGCHLD, signal.SIG_DFL)
    else:
        def noopSignalHandler(*args):
            pass
        signal.signal(signal.SIGCHLD, noopSignalHandler)
        signal.siginterrupt(signal.SIGCHLD, False)
    return signal.set_wakeup_fd(fd) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:23,代码来源:_signals.py

示例2: clone

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def clone(self, proc=None):
        """clone([proc]) clones the supplied process object and manages it as
        well. If no process object is supplied then clone the first managed
        process found in this ProcManager.
        """
        if proc is None: # default to cloning first process found.
            procs = self._procs.values()
            if procs:
                proc = procs[0]
                del procs
            else:
                return
        signal.signal(SIGCHLD, SIG_DFL) # critical area
        newproc = proc.clone()
        self._procs[newproc.childpid] = newproc
        signal.signal(SIGCHLD, self._child_handler)
        signal.siginterrupt(SIGCHLD, False)
        return newproc 
开发者ID:kdart,项目名称:pycopia,代码行数:20,代码来源:proctools.py

示例3: start

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def start(self):
        self.last_profile_time = timer()

        if self.use_signal:
            try:
                signal.signal(signal.SIGALRM, self._signal)
                # the following tells the system to restart interrupted system calls if they are
                # interrupted before any data has been transferred. This avoids many of the problems
                # related to signals interrupting system calls, see issue #16
                signal.siginterrupt(signal.SIGALRM, False)
            except ValueError:
                raise NotMainThreadError()

            signal.setitimer(signal.ITIMER_REAL, self.interval, 0.0)
        else:
            sys.setprofile(self._profile) 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:18,代码来源:profiler.py

示例4: init_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def init_signals(self) -> None:
        # Set up signals through the event loop API.

        self.loop.add_signal_handler(signal.SIGQUIT, self.handle_quit,
                                     signal.SIGQUIT, None)

        self.loop.add_signal_handler(signal.SIGTERM, self.handle_exit,
                                     signal.SIGTERM, None)

        self.loop.add_signal_handler(signal.SIGINT, self.handle_quit,
                                     signal.SIGINT, None)

        self.loop.add_signal_handler(signal.SIGWINCH, self.handle_winch,
                                     signal.SIGWINCH, None)

        self.loop.add_signal_handler(signal.SIGUSR1, self.handle_usr1,
                                     signal.SIGUSR1, None)

        self.loop.add_signal_handler(signal.SIGABRT, self.handle_abort,
                                     signal.SIGABRT, None)

        # Don't let SIGTERM and SIGUSR1 disturb active requests
        # by interrupting system calls
        signal.siginterrupt(signal.SIGTERM, False)
        signal.siginterrupt(signal.SIGUSR1, False) 
开发者ID:TouwaStar,项目名称:Galaxy_Plugin_Bethesda,代码行数:27,代码来源:worker.py

示例5: init_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def init_signals(self):
        # reset signaling
        [signal.signal(s, signal.SIG_DFL) for s in self.SIGNALS]
        # init new signaling
        signal.signal(signal.SIGQUIT, self.handle_quit)
        signal.signal(signal.SIGTERM, self.handle_exit)
        signal.signal(signal.SIGINT, self.handle_quit)
        signal.signal(signal.SIGWINCH, self.handle_winch)
        signal.signal(signal.SIGUSR1, self.handle_usr1)
        signal.signal(signal.SIGABRT, self.handle_abort)

        # Don't let SIGTERM and SIGUSR1 disturb active requests
        # by interrupting system calls
        if hasattr(signal, 'siginterrupt'):  # python >= 2.6
            signal.siginterrupt(signal.SIGTERM, False)
            signal.siginterrupt(signal.SIGUSR1, False) 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:18,代码来源:base.py

示例6: stop

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def stop(self, signum=None, frame=None):
        self.__tmpLog.info('Rank %s: stop signal %s received' % (self.__rank, signum))
        self.__stop = True
        block_sig(signum)
        signal.siginterrupt(signum, False)
        if self.__esJobManager:
            self.__esJobManager.terminate()
        self.getAccountingMetrics()
        self.dumpJobMetrics()
        self.heartbeat()
        #self.__esJobManager.terminate()
        self.__esJobManager.flushMessages()
        self.updateOutputs(signal=True, final=True)

        self.__tmpLog.info("Rank %s: post exec job" % self.__rank)
        self.postExecJob()
        #self.__tmpLog.info("Rank %s: finish job" % self.__rank)
        #self.finishJob()

        self.__tmpLog.info('Rank %s: stop' % self.__rank)
        #signal.siginterrupt(signum, True)
        unblock_sig(signum)
        #sys.exit(0) 
开发者ID:PanDAWMS,项目名称:pilot,代码行数:25,代码来源:Droid.py

示例7: stop

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def stop(self, signum=None, frame=None):
        self.tmpLog.info('stop signal %s received' % signum)
        block_sig(signum)
        signal.siginterrupt(signum, False)
        self.dumpJobMetrics()
        for jobId in self.jobsTimestamp:
            if self.jobsTimestamp[jobId]['endTime'] is None:
                self.jobsTimestamp[jobId]['endTime'] = time.time()
            if len(self.jobsRuningRanks[jobId]) > 0:
                self.jobsTimestamp[jobId]['endTime'] = time.time()
        self.dumpJobsStartTime()
        #self.flushMessages()
        #self.updateFailedEventRanges()
        # final dump
        self.tmpLog.info('final dumping')
        self.updateEventRangesToDB(force=True, final=True)
        #self.db.dumpUpdates(True)
        self.tmpLog.info("post Exec job")
        self.postExecJob()
        self.tmpLog.info('stop')
        #signal.siginterrupt(signum, True)
        unblock_sig(signum) 
开发者ID:PanDAWMS,项目名称:pilot,代码行数:24,代码来源:Yoda.py

示例8: _installHandlerUsingSetWakeup

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def _installHandlerUsingSetWakeup(fd):
    """
    Install a signal handler which will write a byte to C{fd} when
    I{SIGCHLD} is received.

    This is implemented by installing an instance of L{_Handler} wrapped
    around C{None}, setting the I{SIGCHLD} handler as not allowed to
    interrupt system calls, and using L{signal.set_wakeup_fd} to do the
    actual writing.

    @param fd: The file descriptor to which to write when I{SIGCHLD} is
        received.
    @type fd: C{int}
    """
    if fd == -1:
        signal.signal(signal.SIGCHLD, signal.SIG_DFL)
    else:
        signal.signal(signal.SIGCHLD, _Handler(None))
        siginterrupt(signal.SIGCHLD, False)
    return set_wakeup_fd(fd) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:22,代码来源:_signals.py

示例9: handle_unix_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def handle_unix_signals(self):
        if iswindows:
            # TODO: test this on windows
            self.signal_read_socket, self.signal_write_socket = socket.socketpair()
            self.signal_read_socket.setblocking(False)
            self.signal_write_socket.setblocking(False)
            read_fd, write_fd = self.signal_read_socket.fileno(), self.signal_write_socket.fileno()
        else:
            read_fd, write_fd = pipe2()
        for sig in (signal.SIGINT, signal.SIGTERM):
            signal.signal(sig, lambda x, y: None)
            signal.siginterrupt(sig, False)
        signal.set_wakeup_fd(write_fd)
        self.signal_notifier = QSocketNotifier(read_fd, QSocketNotifier.Read, self)
        self.signal_notifier.setEnabled(True)
        self.signal_notifier.activated.connect(self.signal_received, type=Qt.QueuedConnection) 
开发者ID:kovidgoyal,项目名称:vise,代码行数:18,代码来源:main.py

示例10: command

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def command(self):
        setproctitle('taskd')
        self.basic_setup()
        self.keep_running = True
        self.restart_when_done = False
        base.log.info('Starting taskd, pid %s' % os.getpid())
        signal.signal(signal.SIGHUP, self.graceful_restart)
        signal.signal(signal.SIGTERM, self.graceful_stop)
        signal.signal(signal.SIGUSR1, self.log_current_task)
        # restore default behavior of not interrupting system calls
        # see http://docs.python.org/library/signal.html#signal.siginterrupt
        # and http://linux.die.net/man/3/siginterrupt
        signal.siginterrupt(signal.SIGHUP, False)
        signal.siginterrupt(signal.SIGTERM, False)
        signal.siginterrupt(signal.SIGUSR1, False)
        self.worker() 
开发者ID:apache,项目名称:allura,代码行数:18,代码来源:taskd.py

示例11: init_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def init_signals(self):
        # Set up signals through the event loop API.

        self.loop.add_signal_handler(signal.SIGQUIT, self.handle_quit,
                                     signal.SIGQUIT, None)

        self.loop.add_signal_handler(signal.SIGTERM, self.handle_exit,
                                     signal.SIGTERM, None)

        self.loop.add_signal_handler(signal.SIGINT, self.handle_quit,
                                     signal.SIGINT, None)

        self.loop.add_signal_handler(signal.SIGWINCH, self.handle_winch,
                                     signal.SIGWINCH, None)

        self.loop.add_signal_handler(signal.SIGUSR1, self.handle_usr1,
                                     signal.SIGUSR1, None)

        self.loop.add_signal_handler(signal.SIGABRT, self.handle_abort,
                                     signal.SIGABRT, None)

        # Don't let SIGTERM and SIGUSR1 disturb active requests
        # by interrupting system calls
        signal.siginterrupt(signal.SIGTERM, False)
        signal.siginterrupt(signal.SIGUSR1, False) 
开发者ID:skylander86,项目名称:lambda-text-extractor,代码行数:27,代码来源:worker.py

示例12: init_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def init_signals(self):
        # Set up signals through the event loop API.

        self.loop.add_signal_handler(
            signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None
        )

        self.loop.add_signal_handler(
            signal.SIGTERM, self.handle_exit, signal.SIGTERM, None
        )

        self.loop.add_signal_handler(
            signal.SIGINT, self.handle_quit, signal.SIGINT, None
        )

        self.loop.add_signal_handler(
            signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None
        )

        self.loop.add_signal_handler(
            signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None
        )

        self.loop.add_signal_handler(
            signal.SIGABRT, self.handle_abort, signal.SIGABRT, None
        )

        # Don't let SIGTERM and SIGUSR1 disturb active requests
        # by interrupting system calls
        signal.siginterrupt(signal.SIGTERM, False)
        signal.siginterrupt(signal.SIGUSR1, False) 
开发者ID:huge-success,项目名称:sanic,代码行数:33,代码来源:worker.py

示例13: init_signals

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def init_signals(self):
        # reset signaling
        [signal.signal(s, signal.SIG_DFL) for s in self.SIGNALS]
        # init new signaling
        signal.signal(signal.SIGQUIT, self.handle_quit)
        signal.signal(signal.SIGTERM, self.handle_exit)
        signal.signal(signal.SIGINT, self.handle_quit)
        signal.signal(signal.SIGWINCH, self.handle_winch)
        signal.signal(signal.SIGUSR1, self.handle_usr1)
        signal.signal(signal.SIGABRT, self.handle_abort)

        # Don't let SIGTERM and SIGUSR1 disturb active requests
        # by interrupting system calls
        if hasattr(signal, 'siginterrupt'):  # python >= 2.6
            signal.siginterrupt(signal.SIGTERM, False)
            signal.siginterrupt(signal.SIGUSR1, False)

        if hasattr(signal, 'set_wakeup_fd'):
            signal.set_wakeup_fd(self.PIPE[1]) 
开发者ID:jpush,项目名称:jbox,代码行数:21,代码来源:base.py

示例14: main

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def main():
    """Parses the arguments and call worker()"""
    # Set the signal handler
    for s in [signal.SIGINT, signal.SIGTERM]:
        signal.signal(s, shutdown)
        signal.siginterrupt(s, False)
    parser = ArgumentParser(description=__doc__)
    parser.add_argument(
        '--sensor', metavar='SENSOR[:SENSOR]',
        help='sensor to check, optionally with a long name, defaults to all.',
    )
    parser.add_argument(
        '--directory', metavar='DIR',
        help='base directory (defaults to /ivre/passiverecon/).',
        default="/ivre/passiverecon/",
    )
    parser.add_argument(
        '--progname', metavar='PROG',
        help='Program to run (defaults to ivre passiverecon2db).',
        default="ivre passiverecon2db",
    )
    args = parser.parse_args()
    if args.sensor is not None:
        SENSORS.update(dict([args.sensor.split(':', 1)
                             if ':' in args.sensor
                             else [args.sensor, args.sensor]]))
        sensor = args.sensor.split(':', 1)[0]
    else:
        sensor = None
    worker(args.progname, args.directory, sensor=sensor) 
开发者ID:cea-sec,项目名称:ivre,代码行数:32,代码来源:passivereconworker.py

示例15: test_without_siginterrupt

# 需要导入模块: import signal [as 别名]
# 或者: from signal import siginterrupt [as 别名]
def test_without_siginterrupt(self):
        """If a signal handler is installed and siginterrupt is not called
        at all, when that signal arrives, it interrupts a syscall that's in
        progress.
        """
        i = self.readpipe_interrupted()
        self.assertTrue(i)
        # Arrival of the signal shouldn't have changed anything.
        i = self.readpipe_interrupted()
        self.assertTrue(i) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_signal.py


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