Simple file locker.
Project description
iolocker
Simple file locker.
Installation:
python -m pip install [--upgrade] iolocker
Usage:
FileLocker:
# -*- coding: UTF-8 -*-
from iolocker import FileLocker, LOCK
if __name__ == '__main__':
file_handle = open("test_file.txt", "a", encoding="UTF-8")
lock = FileLocker()
fh = lock.acquire(file_handle, flags=LOCK.EX)
fh.write("Testing file lockers...\n")
lock.release(handle=fh)
or as context-manager:
# -*- coding: UTF-8 -*-
from iolocker import FileLocker, LOCK
if __name__ == '__main__':
with open("test_file.txt", "a", encoding="UTF-8") as fh:
with FileLocker(fh, flags=LOCK.EX) as locked:
locked.write("Testing file lockers...\n")
FileHandler:
# -*- coding: UTF-8 -*-
from iolocker import FileHandler
if __name__ == '__main__':
file_path: str = r"test_file.txt"
with FileHandler(file_path, "a", encoding="UTF-8") as fh:
fh.write("Testing file handlers...\n")
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
iolocker-1.1.0.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file iolocker-1.1.0.tar.gz
.
File metadata
- Download URL: iolocker-1.1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7aade1f166f433d4762b18c92da11e60bb8b419f1b037c3ec2bcf919b3816f3 |
|
MD5 | 262463efc10ee96f89031aa17095837a |
|
BLAKE2b-256 | e405278d9df466c9bbd7a565e77d74a4ca0bde85c094c5688fac5a6ad591ae84 |
File details
Details for the file iolocker-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: iolocker-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f37c2a46b7972a827ede3a281892be0618629e0002325091960527f13d87444 |
|
MD5 | 26c6ac411de3c77d08a361ec01ef796f |
|
BLAKE2b-256 | ec89b8fe31cbdc72952b235b723b74cd03c5e0e86df2a3581ff3ba6e93ece661 |