Skip to main content

A simple cross-platform file lock

Project description

EZ File Lock

A simple cross-platform File Lock

Quick start:

pip install ezfilelock

Usage

Use just like builtin method open()

from ezfilelock import open

with open('xxx.txt','r') as f:
    print(f.read())

Use FileLock instance

from ezfilelock import FileLock
from builtin import open

with FileLock('xxx.txt'):
    # do continuous things with lock
    with open('xxx.txt','w') as f:
        f.write('hello')
    with open('xxx.txt','a') as f:
        f.write('world!')
    with open('xxx.txt','r') as f:
        f.read()

Read Write Lock

Cannot Write when Reading.

Cannot Read when Writing.

Can Read by multiple threads at the same time

from ezfilelock import rwopen

with rwopen('xxx.txt',mode='w') as f:
    f.write('hello world')

with rwopen('xxx.txt',mode='r') as f:
    print(f.read())

Project details


Download files

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

Source Distribution

ezfilelock-1.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ezfilelock-1.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file ezfilelock-1.0.1.tar.gz.

File metadata

  • Download URL: ezfilelock-1.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for ezfilelock-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a55e733dc5aee814017db9e815db9eda0bd50d8c7c1a22c1173321eca6c01cb2
MD5 7b09e38934639be111eebb5305c59b6d
BLAKE2b-256 bbddbd14e3bcfe49b18bdd855f6b47c5e05c803e348205229ee48e5c3d2d1ea5

See more details on using hashes here.

File details

Details for the file ezfilelock-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ezfilelock-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for ezfilelock-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80e3375e7c2885f5e787937a2bf38748dee881dee9015fc20665c8e2d82f4054
MD5 41ffddeeea97f0a586e2e87279ac4b19
BLAKE2b-256 a37701eff3fa9903ea913a1be08b2bf2bb34952ea12fecbeeb7851e9e28efe48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page