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


Python signal.SIGCONT屬性代碼示例

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


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

示例1: resume

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def resume(app):
    'Resume apps that have been suspended and arent on the do not suspend list'
    if name_of(app) in DONT_SUSPEND_NAME: 
        print(name_of(app) + ' not resumed, in dont suspend list')
        return
    pids = get_pids(app)
    for pid in pids:
        if pid in SUSPENDED:
            break
    else:
        return
    # only resume pids that are suspended
    logger.debug('Resuming %s (%s)', pids, name_of(app))
    for pid in pids:
        SUSPENDED.discard(pid)
        os.kill(int(pid), signal.SIGCONT)
    for pid in pids:
        os.kill(int(pid), signal.SIGCONT) 
開發者ID:omikun,項目名稱:ForceNap,代碼行數:20,代碼來源:ForceNap.py

示例2: test_wait_stopped

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def test_wait_stopped(self):
        p = self.spawn_psproc()
        if POSIX:
            # Test waitpid() + WIFSTOPPED and WIFCONTINUED.
            # Note: if a process is stopped it ignores SIGTERM.
            p.send_signal(signal.SIGSTOP)
            self.assertRaises(psutil.TimeoutExpired, p.wait, timeout=0.001)
            p.send_signal(signal.SIGCONT)
            self.assertRaises(psutil.TimeoutExpired, p.wait, timeout=0.001)
            p.send_signal(signal.SIGTERM)
            self.assertEqual(p.wait(), -signal.SIGTERM)
            self.assertEqual(p.wait(), -signal.SIGTERM)
        else:
            p.suspend()
            self.assertRaises(psutil.TimeoutExpired, p.wait, timeout=0.001)
            p.resume()
            self.assertRaises(psutil.TimeoutExpired, p.wait, timeout=0.001)
            p.terminate()
            self.assertEqual(p.wait(), signal.SIGTERM)
            self.assertEqual(p.wait(), signal.SIGTERM) 
開發者ID:giampaolo,項目名稱:psutil,代碼行數:22,代碼來源:test_process.py

示例3: _ptrace

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def _ptrace(self, attach):
        op = ctypes.c_int(PTRACE_ATTACH if attach else PTRACE_DETACH)
        c_pid = c_pid_t(self.pid)
        null = ctypes.c_void_p()

        if not attach:
            os.kill(self.pid, signal.SIGSTOP)
            os.waitpid(self.pid, 0)

        err = c_ptrace(op, c_pid, null, null)

        if not attach:
            os.kill(self.pid, signal.SIGCONT)

        if err != 0:
            raise OSError("%s: %s"%(
                'PTRACE_ATTACH' if attach else 'PTRACE_DETACH',
                errno.errorcode.get(ctypes.get_errno(), 'UNKNOWN')
            )) 
開發者ID:n1nj4sec,項目名稱:memorpy,代碼行數:21,代碼來源:LinProcess.py

示例4: execute

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def execute(self,dt):
        if self.finished: return "finished"
        if not self.running:
            self.process = Process(target = executeInProcessGroup, args = (self,))
            self.process.start()
            print "timeshare child PID:",self.process.pid
            os.setpgid(self.process.pid,self.process.pid)
            print "timeshare process group",os.getpgid(self.process.pid)
            assert os.getpgid(self.process.pid) == self.process.pid
            print "my process group",os.getpgrp(),"which should be",os.getpgid(0)
            assert os.getpgid(self.process.pid) != os.getpgid(0)
            self.running = True
        else:
            os.killpg(self.process.pid, signal.SIGCONT)
        
        self.process.join(dt)
        if self.process.is_alive():
            os.killpg(self.process.pid, signal.SIGSTOP)
            return "still running"
        else:
            self.finished = True
            return self.q.get() 
開發者ID:ellisk42,項目名稱:TikZ,代碼行數:24,代碼來源:timeshare.py

示例5: test_shell_background_support_setsid

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def test_shell_background_support_setsid():
    """In setsid mode, dumb-init should suspend itself and its children when it
    receives SIGTSTP, SIGTTOU, or SIGTTIN.
    """
    with print_signals() as (proc, pid):
        for signum in SUSPEND_SIGNALS:
            # both dumb-init and print_signals should be running or sleeping
            assert process_state(pid) in ['running', 'sleeping']
            assert process_state(proc.pid) in ['running', 'sleeping']

            # both should now suspend
            proc.send_signal(signum)

            def assert_both_stopped():
                assert process_state(proc.pid) == process_state(pid) == 'stopped'

            sleep_until(assert_both_stopped)

            # and then both wake up again
            proc.send_signal(SIGCONT)
            assert (
                proc.stdout.readline() == '{}\n'.format(SIGCONT).encode('ascii')
            )
            assert process_state(pid) in ['running', 'sleeping']
            assert process_state(proc.pid) in ['running', 'sleeping'] 
開發者ID:Yelp,項目名稱:dumb-init,代碼行數:27,代碼來源:shell_background_test.py

示例6: test_shell_background_support_without_setsid

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def test_shell_background_support_without_setsid():
    """In non-setsid mode, dumb-init should forward the signals SIGTSTP,
    SIGTTOU, and SIGTTIN, and then suspend itself.
    """
    with print_signals() as (proc, _):
        for signum in SUSPEND_SIGNALS:
            assert process_state(proc.pid) in ['running', 'sleeping']
            proc.send_signal(signum)
            assert proc.stdout.readline() == '{}\n'.format(signum).encode('ascii')
            os.waitpid(proc.pid, os.WUNTRACED)
            assert process_state(proc.pid) == 'stopped'

            proc.send_signal(SIGCONT)
            assert (
                proc.stdout.readline() == '{}\n'.format(SIGCONT).encode('ascii')
            )
            assert process_state(proc.pid) in ['running', 'sleeping'] 
開發者ID:Yelp,項目名稱:dumb-init,代碼行數:19,代碼來源:shell_background_test.py

示例7: test_default_rewrites_can_be_overriden_with_setsid_enabled

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def test_default_rewrites_can_be_overriden_with_setsid_enabled():
    """In setsid mode, dumb-init should allow overwriting the default
    rewrites (but still suspend itself).
    """
    rewrite_map = {
        signal.SIGTTIN: signal.SIGTERM,
        signal.SIGTTOU: signal.SIGINT,
        signal.SIGTSTP: signal.SIGHUP,
    }
    with print_signals(_rewrite_map_to_args(rewrite_map)) as (proc, _):
        for send, expect_receive in rewrite_map.items():
            assert process_state(proc.pid) in ['running', 'sleeping']
            proc.send_signal(send)

            assert proc.stdout.readline() == '{}\n'.format(expect_receive).encode('ascii')
            os.waitpid(proc.pid, os.WUNTRACED)
            assert process_state(proc.pid) == 'stopped'

            proc.send_signal(signal.SIGCONT)
            assert proc.stdout.readline() == '{}\n'.format(signal.SIGCONT).encode('ascii')
            assert process_state(proc.pid) in ['running', 'sleeping'] 
開發者ID:Yelp,項目名稱:dumb-init,代碼行數:23,代碼來源:proxies_signals_test.py

示例8: resume

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def resume(self, unique_id, configs=None):
    """ Issues a sigcont for the specified process

    :Parameter unique_id: the name of the process
    """
    self._send_signal(unique_id, signal.SIGCONT,configs) 
開發者ID:linkedin,項目名稱:Zopkio,代碼行數:8,代碼來源:deployer.py

示例9: clean_exit

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def clean_exit():
    for pid in SUSPENDED:
        os.kill(int(pid), signal.SIGCONT) 
開發者ID:omikun,項目名稱:ForceNap,代碼行數:5,代碼來源:ForceNap.py

示例10: resume

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def resume(self):
        '''
        Resume application and all processes associated with it
        '''
        for pid in self.get_pids():
            if pid in suspended_pids:
                logger.debug('Resuming %s (%s)', self.pid, self.name)
                suspended_pids.discard(pid)
                os.kill(pid, signal.SIGCONT)
        return 
開發者ID:omikun,項目名稱:ForceNap,代碼行數:12,代碼來源:nap_my_app.py

示例11: resume

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def resume(self):
        """Resume process execution with SIGCONT pre-emptively checking
        whether PID has been reused.
        On Windows this has the effect of resuming all process threads.
        """
        if POSIX:
            self._send_signal(signal.SIGCONT)
        else:  # pragma: no cover
            self._proc.resume() 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:11,代碼來源:__init__.py

示例12: terminate

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def terminate(self, force=False):

        """This forces a child process to terminate. It starts nicely with
        SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This
        returns True if the child was terminated. This returns False if the
        child could not be terminated. """

        if not self.isalive():
            return True
        try:
            self.kill(signal.SIGHUP)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGCONT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGINT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            if force:
                self.kill(signal.SIGKILL)
                time.sleep(self.delayafterterminate)
                if not self.isalive():
                    return True
                else:
                    return False
            return False
        except OSError as e:
            # I think there are kernel timing issues that sometimes cause
            # this to happen. I think isalive() reports True, but the
            # process is dead to the kernel.
            # Make one last attempt to see if the kernel is up to date.
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            else:
                return False 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:42,代碼來源:_pexpect.py

示例13: terminate

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def terminate(self, force=False):
        '''This forces a child process to terminate. It starts nicely with
        SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This
        returns True if the child was terminated. This returns False if the
        child could not be terminated. '''

        if not self.isalive():
            return True
        try:
            self.kill(signal.SIGHUP)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGCONT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGINT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            if force:
                self.kill(signal.SIGKILL)
                time.sleep(self.delayafterterminate)
                if not self.isalive():
                    return True
                else:
                    return False
            return False
        except OSError:
            # I think there are kernel timing issues that sometimes cause
            # this to happen. I think isalive() reports True, but the
            # process is dead to the kernel.
            # Make one last attempt to see if the kernel is up to date.
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            else:
                return False 
開發者ID:pypa,項目名稱:pipenv,代碼行數:41,代碼來源:ptyprocess.py

示例14: cont

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def cont(self):
        os.kill(self.childpid, SIGCONT)
        self.deadchild = 0 
開發者ID:kdart,項目名稱:pycopia,代碼行數:5,代碼來源:proctools.py

示例15: terminate

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGCONT [as 別名]
def terminate(self, force = True):
		"""Send a signal to the process in the pty"""
		if self.proc.isalive():

			if os.name == 'nt':
				signals = [signal.SIGINT, signal.SIGTERM]
			else:
				signals = [signal.SIGHUP, signal.SIGCONT, signal.SIGINT,
						   signal.SIGTERM]

			try:
				for sig in signals:
					self.proc.kill(sig)

					if not self.proc.isalive():
						return True

				if force:
					self.proc.kill(signal.SIGKILL)

					if not self.proc.isalive():
						return True

				return False

			except Exception as e:
				if self.proc.isalive():
					return False

		return True 
開發者ID:turingsec,項目名稱:marsnake,代碼行數:32,代碼來源:ptys.py


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