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

fcntl.flock

Prev: fcntl.fcntl | Up: fcntl | Next: fcntl.ioctl
Rel: fcntl.fcntl, fcntl.ioctl, fcntl.lockf
Ref: docs.python.org — fcntl.flock
Tags: #public #python3 #stdlib #fcntl


Import

import fcntl
from fcntl import flock

Signature & Overview

fcntl.flock(fd, operation, /)

Perform the lock operation on file descriptor fd.

Usage

import fcntl
import tempfile

with tempfile.TemporaryFile("w+") as f:
    fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
    fcntl.flock(f, fcntl.LOCK_UN)

Gotchas

REPL Inspect

from fcntl import flock
help(flock)

Linked from

Related notes