def create_subprocess_exec(*args, **kwargs): """ Create a subprocess. @param args: program and arguments @type args: str @param stdin: stdin file descriptor @type stdin: file or int @param stdout: stdout file descriptor @type stdout: file or int @param stderr: stderr file descriptor @type stderr: file or int @param close_fds: close file descriptors @type close_fds: bool @param loop: asyncio.AbstractEventLoop (or compatible) @type loop: event loop @type kwargs: varies @param kwargs: subprocess.Popen parameters @rtype: asyncio.Future (or compatible) @return: subset of asyncio.subprocess.Process interface """ loop = _wrap_loop(kwargs.pop('loop', None)) # Python 3.4 and later implement PEP 446, which makes newly # created file descriptors non-inheritable by default. kwargs.setdefault('close_fds', False) if isinstance(loop._asyncio_wrapper, _AsyncioEventLoop): # Use the real asyncio create_subprocess_exec (loop argument # is deprecated since since Python 3.8). return _real_asyncio.create_subprocess_exec(*args, **kwargs) result = loop.create_future() result.set_result( _Process( subprocess.Popen(args, stdin=kwargs.pop('stdin', None), stdout=kwargs.pop('stdout', None), stderr=kwargs.pop('stderr', None), **kwargs), loop)) return result
def create_subprocess_exec(*args, **kwargs): """ Create a subprocess. @param args: program and arguments @type args: str @param stdin: stdin file descriptor @type stdin: file or int @param stdout: stdout file descriptor @type stdout: file or int @param stderr: stderr file descriptor @type stderr: file or int @param close_fds: close file descriptors @type close_fds: bool @param loop: asyncio.AbstractEventLoop (or compatible) @type loop: event loop @type kwargs: varies @param kwargs: subprocess.Popen parameters @rtype: asyncio.Future (or compatible) @return: subset of asyncio.subprocess.Process interface """ loop = _wrap_loop(kwargs.pop('loop', None)) kwargs.setdefault('close_fds', _close_fds_default) if _asyncio_enabled and isinstance(loop, _AsyncioEventLoop): # Use the real asyncio loop and create_subprocess_exec. return _real_asyncio.create_subprocess_exec(*args, loop=loop._loop, **kwargs) result = loop.create_future() result.set_result( _Process( subprocess.Popen(args, stdin=kwargs.pop('stdin', None), stdout=kwargs.pop('stdout', None), stderr=kwargs.pop('stderr', None), **kwargs), loop)) return result
def create_subprocess_exec(*args, **kwargs): """ Create a subprocess. @param args: program and arguments @type args: str @param stdin: stdin file descriptor @type stdin: file or int @param stdout: stdout file descriptor @type stdout: file or int @param stderr: stderr file descriptor @type stderr: file or int @param close_fds: close file descriptors @type close_fds: bool @param loop: asyncio.AbstractEventLoop (or compatible) @type loop: event loop @type kwargs: varies @param kwargs: subprocess.Popen parameters @rtype: asyncio.Future (or compatible) @return: subset of asyncio.subprocess.Process interface """ loop = _wrap_loop(kwargs.pop('loop', None)) kwargs.setdefault('close_fds', _close_fds_default) if _asyncio_enabled and isinstance(loop, _AsyncioEventLoop): # Use the real asyncio loop and create_subprocess_exec. return _real_asyncio.create_subprocess_exec(*args, loop=loop._loop, **kwargs) result = loop.create_future() result.set_result(_Process(subprocess.Popen( args, stdin=kwargs.pop('stdin', None), stdout=kwargs.pop('stdout', None), stderr=kwargs.pop('stderr', None), **kwargs), loop)) return result