asyncio.create_subprocess_shell
Prev: asyncio.create_subprocess_exec | Up: asyncio | Next: asyncio.create_task
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.create_subprocess_shell
Tags: #public #python3 #stdlib #asyncio
Import
import asyncio
from asyncio import create_subprocess_shell
Signature & Overview
asyncio.create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None, limit=65536, **kwds)
asyncio.create_subprocess_shell() function.
Usage
import asyncio
async def main():
proc = await asyncio.create_subprocess_shell(
"echo async-shell",
stdout=asyncio.subprocess.PIPE,
)
out, _ = await proc.communicate()
assert out.decode().strip() == "async-shell"
asyncio.run(main())
Gotchas
- Never interpolate untrusted input into the command string: Prefer
create_subprocess_exec()unless you explicitly need shell pipelines/globs.
REPL Inspect
from asyncio import create_subprocess_shell
help(create_subprocess_shell)
Linked from
Related notes
- tuts/python3/stdlib_module/asyncio/create_subprocess_exec Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/create_task Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractEventLoop Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractServer Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/all_tasks Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/as_completed Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/Barrier shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseEventLoop shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseProtocol shared tags: #asyncio, #stdlib