On this page
  1. fcntl.lockf
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from fcntl import lockf
help(lockf)

Linked from

Related notes