本文整理汇总了Python中os.P_NOWAIT属性的典型用法代码示例。如果您正苦于以下问题:Python os.P_NOWAIT属性的具体用法?Python os.P_NOWAIT怎么用?Python os.P_NOWAIT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类os
的用法示例。
在下文中一共展示了os.P_NOWAIT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pyspy
# 需要导入模块: import os [as 别名]
# 或者: from os import P_NOWAIT [as 别名]
def pyspy():
"""
This decorator provide deterministic profiling. It generate and save flame graph to file. It uses``pyspy``
internally.
Running py-spy inside of a docker container will also usually bring up a permissions denied error
even when running as root.
This error is caused by docker restricting the process_vm_readv system call we are using. This can be
overridden by setting --cap-add SYS_PTRACE when starting the docker container.
Alternatively you can edit the docker-compose yaml file
.. code-block:: yaml
your_service:
cap_add:
- SYS_PTRACE
In the case of Airflow Breeze, you should modify the ``scripts/perf/perf_kit/python.py`` file.
"""
pid = str(os.getpid())
suffix = datetime.datetime.now().isoformat()
filename = f"{PYSPY_OUTPUT}/flame-{suffix}-{pid}.html"
pyspy_pid = os.spawnlp(
os.P_NOWAIT, "sudo", "sudo", "py-spy", "record", "--idle", "-o", filename, "-p", pid
)
try:
yield
finally:
os.kill(pyspy_pid, signal.SIGINT)
print(f"Report saved to: {filename}")
示例2: launch_wxglade
# 需要导入模块: import os [as 别名]
# 或者: from os import P_NOWAIT [as 别名]
def launch_wxglade(self, options, wait=False):
path = self.GetWxGladePath()
glade = os.path.join(path, 'wxglade.py')
if wx.Platform == '__WXMSW__':
glade = "\"%s\"" % glade
mode = {False: os.P_NOWAIT, True: os.P_WAIT}[wait]
os.spawnv(mode, sys.executable,
["\"%s\"" % sys.executable] + [glade] + options)
示例3: _reload
# 需要导入模块: import os [as 别名]
# 或者: from os import P_NOWAIT [as 别名]
def _reload() -> None:
global _reload_attempted
_reload_attempted = True
for fn in _reload_hooks:
fn()
if hasattr(signal, "setitimer"):
# Clear the alarm signal set by
# ioloop.set_blocking_log_threshold so it doesn't fire
# after the exec.
signal.setitimer(signal.ITIMER_REAL, 0, 0)
# sys.path fixes: see comments at top of file. If __main__.__spec__
# exists, we were invoked with -m and the effective path is about to
# change on re-exec. Reconstruct the original command line to
# ensure that the new process sees the same path we did. If
# __spec__ is not available (Python < 3.4), check instead if
# sys.path[0] is an empty string and add the current directory to
# $PYTHONPATH.
if _autoreload_is_main:
assert _original_argv is not None
spec = _original_spec
argv = _original_argv
else:
spec = getattr(sys.modules["__main__"], "__spec__", None)
argv = sys.argv
if spec:
argv = ["-m", spec.name] + argv[1:]
else:
path_prefix = "." + os.pathsep
if sys.path[0] == "" and not os.environ.get("PYTHONPATH", "").startswith(
path_prefix
):
os.environ["PYTHONPATH"] = path_prefix + os.environ.get("PYTHONPATH", "")
if not _has_execv:
subprocess.Popen([sys.executable] + argv)
os._exit(0)
else:
try:
os.execv(sys.executable, [sys.executable] + argv)
except OSError:
# Mac OS X versions prior to 10.6 do not support execv in
# a process that contains multiple threads. Instead of
# re-executing in the current process, start a new one
# and cause the current process to exit. This isn't
# ideal since the new process is detached from the parent
# terminal and thus cannot easily be killed with ctrl-C,
# but it's better than not being able to autoreload at
# all.
# Unfortunately the errno returned in this case does not
# appear to be consistent, so we can't easily check for
# this error specifically.
os.spawnv( # type: ignore
os.P_NOWAIT, sys.executable, [sys.executable] + argv
)
# At this point the IOLoop has been closed and finally
# blocks will experience errors if we allow the stack to
# unwind, so just exit uncleanly.
os._exit(0)
示例4: downloadfileRTMP
# 需要导入模块: import os [as 别名]
# 或者: from os import P_NOWAIT [as 别名]
def downloadfileRTMP(url, nombrefichero, silent):
''' No usa librtmp ya que no siempre está disponible.
Lanza un subproceso con rtmpdump. En Windows es necesario instalarlo.
No usa threads así que no muestra ninguna barra de progreso ni tampoco
se marca el final real de la descarga en el log info.
'''
Programfiles = os.getenv('Programfiles')
if Programfiles: # Windows
rtmpdump_cmd = Programfiles + "/rtmpdump/rtmpdump.exe"
nombrefichero = '"' + nombrefichero + '"' # Windows necesita las comillas en el nombre
else:
rtmpdump_cmd = "/usr/bin/rtmpdump"
if not filetools.isfile(rtmpdump_cmd) and not silent:
from platformcode import platformtools
advertencia = platformtools.dialog_ok("Falta " + rtmpdump_cmd, "Comprueba que rtmpdump está instalado")
return True
valid_rtmpdump_options = ["help", "url", "rtmp", "host", "port", "socks", "protocol", "playpath", "playlist",
"swfUrl", "tcUrl", "pageUrl", "app", "swfhash", "swfsize", "swfVfy", "swfAge", "auth",
"conn", "flashVer", "live", "subscribe", "realtime", "flv", "resume", "timeout", "start",
"stop", "token", "jtv", "hashes", "buffer", "skip", "quiet", "verbose",
"debug"] # for rtmpdump 2.4
url_args = url.split(' ')
rtmp_url = url_args[0]
rtmp_args = url_args[1:]
rtmpdump_args = ["--rtmp", rtmp_url]
for arg in rtmp_args:
n = arg.find('=')
if n < 0:
if arg not in valid_rtmpdump_options:
continue
rtmpdump_args += ["--" + arg]
else:
if arg[:n] not in valid_rtmpdump_options:
continue
rtmpdump_args += ["--" + arg[:n], arg[n + 1:]]
try:
rtmpdump_args = [rtmpdump_cmd] + rtmpdump_args + ["-o", nombrefichero]
from os import spawnv, P_NOWAIT
logger.info("Iniciando descarga del fichero: %s" % " ".join(rtmpdump_args))
rtmpdump_exit = spawnv(P_NOWAIT, rtmpdump_cmd, rtmpdump_args)
if not silent:
from platformcode import platformtools
advertencia = platformtools.dialog_ok("La opción de descarga RTMP es experimental",
"y el vídeo se descargará en segundo plano.",
"No se mostrará ninguna barra de progreso.")
except:
return True
return
示例5: downloadfileRTMP
# 需要导入模块: import os [as 别名]
# 或者: from os import P_NOWAIT [as 别名]
def downloadfileRTMP(url,nombrefichero,silent):
''' No usa librtmp ya que no siempre está disponible.
Lanza un subproceso con rtmpdump. En Windows es necesario instalarlo.
No usa threads así que no muestra ninguna barra de progreso ni tampoco
se marca el final real de la descarga en el log info.
'''
Programfiles = os.getenv('Programfiles')
if Programfiles: # Windows
rtmpdump_cmd = Programfiles + "/rtmpdump/rtmpdump.exe"
nombrefichero = '"'+nombrefichero+'"' # Windows necesita las comillas en el nombre
else:
rtmpdump_cmd = "/usr/bin/rtmpdump"
if not os.path.isfile(rtmpdump_cmd) and not silent:
from platformcode import platformtools
advertencia = platformtools.dialog_ok( "Falta " + rtmpdump_cmd, "Comprueba que rtmpdump está instalado")
return True
valid_rtmpdump_options = ["help", "url", "rtmp", "host", "port", "socks", "protocol", "playpath", "playlist", "swfUrl", "tcUrl", "pageUrl", "app", "swfhash", "swfsize", "swfVfy", "swfAge", "auth", "conn", "flashVer", "live", "subscribe", "realtime", "flv", "resume", "timeout", "start", "stop", "token", "jtv", "hashes", "buffer", "skip", "quiet", "verbose", "debug"] # for rtmpdump 2.4
url_args = url.split(' ')
rtmp_url = url_args[0]
rtmp_args = url_args[1:]
rtmpdump_args = ["--rtmp", rtmp_url]
for arg in rtmp_args:
n = arg.find('=')
if n < 0:
if arg not in valid_rtmpdump_options:
continue
rtmpdump_args += ["--"+arg]
else:
if arg[:n] not in valid_rtmpdump_options:
continue
rtmpdump_args += ["--"+arg[:n], arg[n+1:]]
try:
rtmpdump_args = [rtmpdump_cmd] + rtmpdump_args + ["-o", nombrefichero]
from os import spawnv, P_NOWAIT
logger.info("Iniciando descarga del fichero: %s" % " ".join(rtmpdump_args))
rtmpdump_exit = spawnv(P_NOWAIT, rtmpdump_cmd, rtmpdump_args)
if not silent:
from platformcode import platformtools
advertencia = platformtools.dialog_ok( "La opción de descarga RTMP es experimental", "y el vídeo se descargará en segundo plano.", "No se mostrará ninguna barra de progreso.")
except:
return True
return