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


Python signal.SIGWINCH屬性代碼示例

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


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

示例1: test_save_signal_state

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def test_save_signal_state(self):
        """Tests that the signal state class works properly.

        The _SignalState class must set, save, and restore signals
        when needed.
        """
        if sys.platform == "win32":
            self.skipTest("Windows does not have signals.")

        def dummy_handler():
            """Assign dummy handler to an arbitrary signal."""
            pass
        self.assertNotEqual(signal.getsignal(signal.SIGWINCH), dummy_handler)
        signal_state = _SignalState()
        signal_state.set(signal.SIGWINCH, dummy_handler)
        self.assertEqual(signal.getsignal(signal.SIGWINCH), dummy_handler)
        signal_state.restore()
        self.assertNotEqual(signal.getsignal(signal.SIGWINCH), dummy_handler) 
開發者ID:peterbrittain,項目名稱:asciimatics,代碼行數:20,代碼來源:test_screen.py

示例2: test_signal

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def test_signal(self):
        """
        Check that signals are restored after using _CursesScreen
        """
        if sys.platform == "win32":
            self.skipTest("Windows does not have signals.")

        def dummy_signal_handler():
            """Dummy previous signal handler."""
            pass
        outer_state = _SignalState()
        self.assertNotEqual(signal.getsignal(signal.SIGWINCH), dummy_signal_handler)
        outer_state.set(signal.SIGWINCH, dummy_signal_handler)
        self.assertEqual(signal.getsignal(signal.SIGWINCH), dummy_signal_handler)
        Screen.wrapper(self.signal_check)
        self.assertEqual(signal.getsignal(signal.SIGWINCH), dummy_signal_handler)
        outer_state.restore()
        self.assertNotEqual(signal.getsignal(signal.SIGWINCH), dummy_signal_handler) 
開發者ID:peterbrittain,項目名稱:asciimatics,代碼行數:20,代碼來源:test_screen.py

示例3: _shocker_thread

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def _shocker_thread(self):
        # On Linux, ignored signals still cause a notification under ptrace.
        # Hence, we use SIGWINCH, harmless and ignored signal to make wait4 return
        # pt_process::monitor, causing time to be updated.
        # On FreeBSD, a signal must not be ignored in order for wait4 to return.
        # Hence, we swallow SIGSTOP, which should never be used anyway, and use it
        # force an update.
        wake_signal = signal.SIGSTOP if 'freebsd' in sys.platform else signal.SIGWINCH
        self._spawned_or_errored.wait()

        while not self._died.wait(1):
            if self.execution_time > self._time or self.wall_clock_time > self._wall_time:
                log.warning('Shocker activated and killed %d', self.pid)
                self.kill()
                self._is_tle = True
                break
            try:
                os.killpg(self.pid, wake_signal)
            except OSError:
                pass 
開發者ID:DMOJ,項目名稱:judge-server,代碼行數:22,代碼來源:tracer.py

示例4: init_signals

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [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 SIGWINCH [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

示例6: init_signals

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [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

示例7: signal_check

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def signal_check(self, screen):
        """Dummy callback for screen wrapper."""
        self.assertEqual(signal.getsignal(signal.SIGWINCH), screen._resize_handler) 
開發者ID:peterbrittain,項目名稱:asciimatics,代碼行數:5,代碼來源:test_screen.py

示例8: select_profile

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def select_profile(profile_list):
    selection = await radiolist_dialog(
        title="Select AnyConnect profile",
        text=HTML(
            "The following AnyConnect profiles are detected.\n"
            "The selection will be <b>saved</b> and not asked again unless the <pre>--profile-selector</pre> command line option is used"
        ),
        values=[(p, p.name) for i, p in enumerate(profile_list)],
    ).run_async()
    asyncio.get_event_loop().remove_signal_handler(signal.SIGWINCH)
    if not selection:
        return selection
    logger.info("Selected profile", profile=selection.name)
    return selection 
開發者ID:vlaci,項目名稱:openconnect-sso,代碼行數:16,代碼來源:app.py

示例9: start

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def start(self):
        """
        Start trapping WINCH signals and resizing the PTY.

        This method saves the previous WINCH handler so it can be restored on
        `stop()`.
        """

        def handle(signum, frame):
            if signum == signal.SIGWINCH:
                self.pty.resize()

        self.original_handler = signal.signal(signal.SIGWINCH, handle) 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:15,代碼來源:pty.py

示例10: stop

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def stop(self):
        """
        Stop trapping WINCH signals and restore the previous WINCH handler.
        """

        if self.original_handler is not None:
            signal.signal(signal.SIGWINCH, self.original_handler) 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:9,代碼來源:pty.py

示例11: cmd_start_server

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def cmd_start_server(params):
    formatter = optparse.IndentedHelpFormatter()
    formatter.set_long_opt_delimiter(' ')

    usage = '%prog start-server script [options]'
    parser = optparse.OptionParser(usage=usage, option_list=option_list,
            formatter=formatter)

    (options, args) = parser.parse_args(params)

    config = _cmd_setup_server('start-server', args, vars(options))

    if config['setup_only']:
        return

    executable = os.path.join(config['server_root'], 'apachectl')

    if config['isatty'] and sys.stdout.isatty():
        process = None

        def handler(signum, frame):
            if process is None:
                sys.exit(1)

            else:
                if signum not in [signal.SIGWINCH]:
                    os.kill(process.pid, signum)

        signal.signal(signal.SIGINT, handler)
        signal.signal(signal.SIGTERM, handler)
        signal.signal(signal.SIGHUP, handler)
        signal.signal(signal.SIGUSR1, handler)
        signal.signal(signal.SIGWINCH, handler)

        process = subprocess.Popen([executable, 'start', '-DFOREGROUND'],
                preexec_fn=os.setpgrp)

        process.wait()

    else:
        os.execl(executable, executable, 'start', '-DFOREGROUND') 
開發者ID:acaceres2176,項目名稱:scylla,代碼行數:43,代碼來源:__init__.py

示例12: resize

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def resize(self, rows, cols, em_dimensions=None, ctrl_l=True):
        """
        Resizes the child process's terminal window to *rows* and *cols* by
        first sending it a TIOCSWINSZ event and then sending ctrl-l.

        If *em_dimensions* are provided they will be updated along with the
        rows and cols.

        The sending of ctrl-l can be disabled by setting *ctrl_l* to False.
        """
        logging.debug(
            "Resizing term %s to rows: %s, cols: %s, em_dimensions=%s"
            % (self.term_id, rows, cols, em_dimensions))
        if rows < 2:
            rows = 24
        if cols < 2:
            cols = 80
        self.rows = rows
        self.cols = cols
        self.term.resize(rows, cols, em_dimensions)
        # Sometimes the resize doesn't actually apply (for whatever reason)
        # so to get around this we have to send a different value than the
        # actual value we want then send our actual value.  It's a bug outside
        # of Gate One that I have no idea how to isolate but this has proven to
        # be an effective workaround.
        import fcntl, termios
        s = struct.pack("HHHH", rows, cols, 0, 0)
        try:
            fcntl.ioctl(self.fd, termios.TIOCSWINSZ, s)
        except IOError:
            # Process already ended--no big deal
            return
        try:
            os.kill(self.pid, signal.SIGWINCH) # Send the resize signal
        except OSError:
            return # Process is dead.  Can happen when things go quickly
        if ctrl_l:
            self.write(u'\x0c') # ctrl-l 
開發者ID:jimmy201602,項目名稱:django-gateone,代碼行數:40,代碼來源:termio.py

示例13: __enter__

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def __enter__(self) -> None:
        tuple(map(lambda x: self.asycio_loop.add_signal_handler(*x), (
            (signal.SIGWINCH, self.on_winch),
            (signal.SIGINT, self.on_interrupt),
            (signal.SIGTERM, self.on_term)
        ))) 
開發者ID:kovidgoyal,項目名稱:kitty,代碼行數:8,代碼來源:loop.py

示例14: __exit__

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def __exit__(self, *a: Any) -> None:
        tuple(map(self.asycio_loop.remove_signal_handler, (
            signal.SIGWINCH, signal.SIGINT, signal.SIGTERM))) 
開發者ID:kovidgoyal,項目名稱:kitty,代碼行數:5,代碼來源:loop.py

示例15: test_kbhit_interrupted

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGWINCH [as 別名]
def test_kbhit_interrupted():
    "kbhit() should not be interrupted with a signal handler."
    pid, master_fd = pty.fork()
    if pid is 0:
        try:
            cov = __import__('cov_core_init').init()
        except ImportError:
            cov = None

        # child pauses, writes semaphore and begins awaiting input
        global got_sigwinch
        got_sigwinch = False

        def on_resize(sig, action):
            global got_sigwinch
            got_sigwinch = True

        term = TestTerminal()
        signal.signal(signal.SIGWINCH, on_resize)
        read_until_semaphore(sys.__stdin__.fileno(), semaphore=SEMAPHORE)
        os.write(sys.__stdout__.fileno(), SEMAPHORE)
        with term.raw():
            assert term.inkey(timeout=1.05) == u''
        os.write(sys.__stdout__.fileno(), b'complete')
        assert got_sigwinch is True
        if cov is not None:
            cov.stop()
            cov.save()
        os._exit(0)

    with echo_off(master_fd):
        os.write(master_fd, SEND_SEMAPHORE)
        read_until_semaphore(master_fd)
        stime = time.time()
        os.kill(pid, signal.SIGWINCH)
        output = read_until_eof(master_fd)

    pid, status = os.waitpid(pid, 0)
    assert output == u'complete'
    assert os.WEXITSTATUS(status) == 0
    assert math.floor(time.time() - stime) == 1.0 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:43,代碼來源:test_keyboard.py


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