本文整理汇总了Python中os.WIFEXITED属性的典型用法代码示例。如果您正苦于以下问题:Python os.WIFEXITED属性的具体用法?Python os.WIFEXITED怎么用?Python os.WIFEXITED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类os
的用法示例。
在下文中一共展示了os.WIFEXITED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: poll
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def poll(self, flag=os.WNOHANG):
if self.returncode is None:
while True:
try:
pid, sts = os.waitpid(self.pid, flag)
except os.error as e:
if e.errno == errno.EINTR:
continue
# Child process not yet created. See #1731717
# e.errno == errno.ECHILD == 10
return None
else:
break
if pid == self.pid:
if os.WIFSIGNALED(sts):
self.returncode = -os.WTERMSIG(sts)
else:
assert os.WIFEXITED(sts)
self.returncode = os.WEXITSTATUS(sts)
return self.returncode
示例2: platformProcessEvent
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def platformProcessEvent(self, status):
if os.WIFEXITED(status):
tid = self.getMeta("ThreadId", -1)
if tid != self.getPid():
# Set the selected thread ID to the pid cause
# the old one's invalid
if tid in self.pthreads:
self.pthreads.remove(tid)
self.setMeta("ThreadId", self.getPid())
self._fireExitThread(tid, os.WEXITSTATUS(status))
else:
self._fireExit(os.WEXITSTATUS(status))
elif os.WIFSIGNALED(status):
self.setMeta("ExitCode", os.WTERMSIG(status))
self.fireNotifiers(vtrace.NOTIFY_EXIT)
elif os.WIFSTOPPED(status):
sig = os.WSTOPSIG(status)
self.handlePosixSignal(sig)
else:
print "OMG WTF JUST HAPPENED??!?11/!?1?>!"
示例3: exitStatus
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def exitStatus(self, code):
"""
Construct a status from the given exit code.
@type code: L{int} between 0 and 255 inclusive.
@param code: The exit status which the code will represent.
@rtype: L{int}
@return: A status integer for the given exit code.
"""
# /* Macros for constructing status values. */
# #define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
status = (code << 8) | 0
# Sanity check
self.assertTrue(os.WIFEXITED(status))
self.assertEqual(os.WEXITSTATUS(status), code)
self.assertFalse(os.WIFSIGNALED(status))
return status
示例4: signalStatus
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def signalStatus(self, signal):
"""
Construct a status from the given signal.
@type signal: L{int} between 0 and 255 inclusive.
@param signal: The signal number which the status will represent.
@rtype: L{int}
@return: A status integer for the given signal.
"""
# /* If WIFSIGNALED(STATUS), the terminating signal. */
# #define __WTERMSIG(status) ((status) & 0x7f)
# /* Nonzero if STATUS indicates termination by a signal. */
# #define __WIFSIGNALED(status) \
# (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
status = signal
# Sanity check
self.assertTrue(os.WIFSIGNALED(status))
self.assertEqual(os.WTERMSIG(status), signal)
self.assertFalse(os.WIFEXITED(status))
return status
示例5: GetExitStatus
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def GetExitStatus(exit_code):
"""Returns the argument to exit(), or -1 if exit() wasn't called.
Args:
exit_code: the result value of os.system(command).
"""
if os.name == 'nt':
# On Windows, os.WEXITSTATUS() doesn't work and os.system() returns
# the argument to exit() directly.
return exit_code
else:
# On Unix, os.WEXITSTATUS() must be used to extract the exit status
# from the result of os.system().
if os.WIFEXITED(exit_code):
return os.WEXITSTATUS(exit_code)
else:
return -1
示例6: GetExitStatus
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def GetExitStatus(exit_code):
"""Returns the argument to exit(), or -1 if exit() wasn't called.
Args:
exit_code: the result value of os.system(command).
"""
if os.name == 'nt':
# On Windows, os.WEXITSTATUS() doesn't work and os.system() returns
# the argument to exit() directly.
return exit_code
else:
# On Unix, os.WEXITSTATUS() must be used to extract the exit status
# from the result of os.system().
if os.WIFEXITED(exit_code):
return os.WEXITSTATUS(exit_code)
else:
return -1
# Suppresses the "Invalid const name" lint complaint
# pylint: disable-msg=C6409
# Exposes utilities from gtest_test_utils.
示例7: poll
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def poll(self, flag=os.WNOHANG):
if self.returncode is None:
while True:
try:
pid, sts = os.waitpid(self.pid, flag)
except OSError as e:
# Child process not yet created. See #1731717
# e.errno == errno.ECHILD == 10
return None
else:
break
if pid == self.pid:
if os.WIFSIGNALED(sts):
self.returncode = -os.WTERMSIG(sts)
else:
assert os.WIFEXITED(sts)
self.returncode = os.WEXITSTATUS(sts)
return self.returncode
示例8: _handle_exitstatus
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
_WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
_WEXITSTATUS=os.WEXITSTATUS, _WIFSTOPPED=os.WIFSTOPPED,
_WSTOPSIG=os.WSTOPSIG):
"""All callers to this function MUST hold self._waitpid_lock."""
# This method is called (indirectly) by __del__, so it cannot
# refer to anything outside of its local scope.
if _WIFSIGNALED(sts):
self.returncode = -_WTERMSIG(sts)
elif _WIFEXITED(sts):
self.returncode = _WEXITSTATUS(sts)
elif _WIFSTOPPED(sts):
self.returncode = -_WSTOPSIG(sts)
else:
# Should never happen
raise SubprocessError("Unknown child exit status!")
示例9: __callback__
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def __callback__(self, handle, status):
try:
pid = self._handles.pop(handle)
source, callback, args, handle = self._sources.pop(pid)
except KeyError:
return
self._close_process_handle(handle)
GLib.source_remove(source)
if hasattr(os, "WIFSIGNALED") and os.WIFSIGNALED(status):
returncode = -os.WTERMSIG(status)
elif hasattr(os, "WIFEXITED") and os.WIFEXITED(status):
returncode = os.WEXITSTATUS(status)
# FIXME: Hack for adjusting invalid status returned by GLIB
# Looks like there is a bug in glib or in pygobject
if returncode > 128:
returncode = 128 - returncode
else:
returncode = status
callback(pid, returncode, *args)
示例10: wait_on_children
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def wait_on_children(self):
while self.running:
try:
pid, status = os.wait()
if os.WIFEXITED(status) or os.WIFSIGNALED(status):
self._remove_children(pid)
self._verify_and_respawn_children(pid, status)
except OSError as err:
if err.errno not in (errno.EINTR, errno.ECHILD):
raise
except KeyboardInterrupt:
LOG.info('Caught keyboard interrupt. Exiting.')
break
except exception.SIGHUPInterrupt:
self.reload()
continue
eventlet.greenio.shutdown_safe(self.sock)
self.sock.close()
LOG.debug('Exited')
示例11: poll
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def poll(self, flag=os.WNOHANG):
if self.returncode is None:
while True:
try:
pid, sts = os.waitpid(self.pid, flag)
except OSError as e:
if e.errno == errno.EINTR:
continue
# Child process not yet created. See #1731717
# e.errno == errno.ECHILD == 10
return None
else:
break
if pid == self.pid:
if os.WIFSIGNALED(sts):
self.returncode = -os.WTERMSIG(sts)
else:
assert os.WIFEXITED(sts)
self.returncode = os.WEXITSTATUS(sts)
return self.returncode
示例12: _do_waitpid
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def _do_waitpid(self, loop, expected_pid, callback, args):
assert expected_pid > 0
try:
pid, status = os.waitpid(expected_pid, 0)
except ChildProcessError:
# The child process is already reaped
# (may happen if waitpid() is called elsewhere).
pid = expected_pid
returncode = 255
logger.warning(
"Unknown child process pid %d, will report returncode 255", pid
)
else:
if os.WIFSIGNALED(status):
returncode = -os.WTERMSIG(status)
elif os.WIFEXITED(status):
returncode = os.WEXITSTATUS(status)
else:
returncode = status
if loop.get_debug():
logger.debug(
"process %s exited with returncode %s", expected_pid, returncode
)
if loop.is_closed():
logger.warning("Loop %r that handles pid %r is closed", loop, pid)
else:
loop.call_soon_threadsafe(callback, pid, returncode, *args)
self._threads.pop(expected_pid)
# add the watcher to the loop policy
示例13: _handle_exitstatus
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
_WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
_WEXITSTATUS=os.WEXITSTATUS):
# This method is called (indirectly) by __del__, so it cannot
# refer to anything outside of its local scope."""
if _WIFSIGNALED(sts):
self.returncode = -_WTERMSIG(sts)
elif _WIFEXITED(sts):
self.returncode = _WEXITSTATUS(sts)
else:
# Should never happen
raise RuntimeError("Unknown child exit status!")
示例14: _set_returncode
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def _set_returncode(self, status):
if os.WIFSIGNALED(status):
self.returncode = -os.WTERMSIG(status)
else:
assert os.WIFEXITED(status)
self.returncode = os.WEXITSTATUS(status)
if self._exit_callback:
callback = self._exit_callback
self._exit_callback = None
callback(self.returncode)
示例15: _on_sigchld
# 需要导入模块: import os [as 别名]
# 或者: from os import WIFEXITED [as 别名]
def _on_sigchld(self, watcher):
"""Callback of libev child watcher. Called when libev event loop
catches corresponding SIGCHLD signal.
"""
watcher.stop()
# Status evaluation copied from `multiprocessing.forking` in Py2.7.
if os.WIFSIGNALED(watcher.rstatus):
self._popen.returncode = -os.WTERMSIG(watcher.rstatus)
else:
assert os.WIFEXITED(watcher.rstatus)
self._popen.returncode = os.WEXITSTATUS(watcher.rstatus)
self._returnevent.set()
log.debug("SIGCHLD watcher callback for %s invoked. Exitcode "
"stored: %s", self.pid, self._popen.returncode)