Skip to main content

A platform independent file lock.

Project description

This package contains a single module, which implements a platform independent file lock in Python.

The lock includes a lock counter and is thread safe. This means, when locking the same lock object twice, it will not block.

import filelock

lock = filelock.FileLock("my_lock_file")

with lock:

        with lock.acquire(timeout = 10):
except filelock.Timeout:

What this filelock is not

A filelock provides a synchronisation mechanism between different instances of your application, similar to a thread lock. It can be used to signalize that files, directories or other resources are currently used or manipulated (Think of a sync.lock file). Only the existence of the lockfile is watched for this purpose. The file itself can not be written and is always empty.

Perhaps you are looking for something like


The full documentation is available on


Contributions are always welcome. Never hesitate to open a new issue.


This package is public domain.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for filelock, version 2.0.9
Filename, size File type Python version Upload date Hashes
Filename, size filelock-2.0.9.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page