On this page
os.pipe
Prev: os.open | Up: os | Next: os.putenv
Rel: os.abort, os.access, os.chdir, os.chmod
Ref: docs.python.org — os.pipe
Tags: #public #python3 #stdlib #os
Import
import os
from os import pipe
Signature & Overview
os.pipe()
Create a pipe.
Usage
import os
r_fd, w_fd = os.pipe()
try:
os.write(w_fd, b"ping")
assert os.read(r_fd, 4) == b"ping"
finally:
os.close(r_fd); os.close(w_fd)
Gotchas
- Returns
(read_fd, write_fd)non-inheritable descriptors: Always close both ends (or wrap withos.fdopen()) to prevent fd leaks.
REPL Inspect
from os import pipe
help(pipe)
Linked from
Related notes
- tuts/python3/stdlib_module/os/open Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/putenv Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/os/abort Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/access Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chdir Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chmod Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chown shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/close shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/cpu_count shared tags: #os, #stdlib