Python os.P_NOWAIT Examples
The following are 8
code examples of os.P_NOWAIT().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: python.py From airflow with Apache License 2.0 | 5 votes |
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}")
Example #2
Source File: wxglade_hmi.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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)
Example #3
Source File: autoreload.py From opendevops with GNU General Public License v3.0 | 4 votes |
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)
Example #4
Source File: autoreload.py From teleport with Apache License 2.0 | 4 votes |
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)
Example #5
Source File: autoreload.py From teleport with Apache License 2.0 | 4 votes |
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)
Example #6
Source File: downloadtools.py From addon with GNU General Public License v3.0 | 4 votes |
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
Example #7
Source File: downloadtools.py From pelisalacarta-ce with GNU General Public License v3.0 | 4 votes |
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
Example #8
Source File: autoreload.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 4 votes |
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)