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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for ezfilelock-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80e3375e7c2885f5e787937a2bf38748dee881dee9015fc20665c8e2d82f4054 |
|
MD5 | 41ffddeeea97f0a586e2e87279ac4b19 |
|
BLAKE2b-256 | a37701eff3fa9903ea913a1be08b2bf2bb34952ea12fecbeeb7851e9e28efe48 |