Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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())

About

a simple cross platform file lock

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages