On this page
fcntl.lockf
Prev: fcntl.ioctl | Up: fcntl
Rel: fcntl.fcntl, fcntl.flock, fcntl.ioctl
Ref: docs.python.org — fcntl.lockf
Tags: #public #python3 #stdlib #fcntl
Import
import fcntl
from fcntl import lockf
Signature & Overview
fcntl.lockf(fd, cmd, len=0, start=0, whence=0, /)
A wrapper around the fcntl() locking calls.
Usage
import fcntl
import tempfile
with tempfile.TemporaryFile("w+b") as f:
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
fcntl.lockf(f, fcntl.LOCK_UN)
Gotchas
- POSIX
fcntl-backed byte-range lock: Unlikeflock(), closing any duplicate fd to the same file in the process releases alllockflocks on that file.
REPL Inspect
from fcntl import lockf
help(lockf)
Linked from
Related notes
- tuts/python3/stdlib_module/fcntl/fcntl Linked here; links to this page; shared tags: #fcntl, #stdlib
- tuts/python3/stdlib_module/fcntl/flock Linked here; links to this page; shared tags: #fcntl, #stdlib
- tuts/python3/stdlib_module/fcntl/ioctl Linked here; links to this page; shared tags: #fcntl, #stdlib
- tuts/python3/stdlib_module/fcntl links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib