Skip to main content

rename_lock

下の方に日本語の説明があります

Overview

  • Easy file exclusive locking tool based on file rename.

Usage

  • While you are in "WITH" area, the file is locked and cannot be edited by any other process.
  • While locked, the file will be renamed to "original_name_random_string.locked"
    • The name can be obtained with rlock.filename
import rename_lock

with rename_lock("./demo_file.txt") as rlock:
	# operation on locked file
	temp_filename = rlock.filename	# temporary file name
	with open(temp_filename, "w") as f:
		f.write("something")
  • About Unlocking

    • The lock is automatically unlocked when exiting "WITH" area.
    • Also, when using "WITH", it will automatically unlock when stopped due to an error or when stopped by ctrl+C.
    • However, there may be cases where the file is not unlocked, such as when the entire window is erased.
  • The following is how to write when not using "WITH".

rlock = rename_lock("./demo_file.txt")
print(rlock.filename)
rlock.unlock()

概要

  • 手軽なファイルの排他ロックツール
    • ファイルの名称変更を動作原理とする

使用例

  • 下記のように、with内にいる間ファイルの編集がロックされます
  • ロック中はファイルは「元の名前_ランダム文字列.locked」という名前に変更されます
    • その名前はrlock.filenameで取得できます
import rename_lock

with rename_lock("./demo_file.txt") as rlock:
	# lockしたファイルに対する操作を書く
	temp_filename = rlock.filename	# temporary file name
	with open(temp_filename, "w") as f:
		f.write("something")
  • ロック解除について

    • withを抜けると自動的にロック解除されます
    • また、エラーによる停止やctrl+Cによる停止時にも、withを使っている場合は自動的にロック解除されます
    • ただし、ウィンドウごと消した場合など、ロック解除されない場合もあります
  • 下記はwithを使わない場合の書き方です

rlock = rename_lock("./demo_file.txt")
print(rlock.filename)
rlock.unlock()

Metadata

Release files for rename-lock 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rename-lock 0.1.4
File Size Uploaded Provenance
rename-lock-0.1.4.tar.gz 3.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for rename-lock 0.1.4
File Interpreter ABI Platform
rename_lock-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / rename-lock-0.1.4.tar.gz

Download URL rename-lock-0.1.4.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b511703bde859eaa676ed00c6a4f4eee86ce1bbfba17e831ecae4707d9fd13b1
BLAKE2b-256 checksum
How to use checksums
c203bccf3bdf568970d4829cb800ba6041e15d5f501c23f55a5b7e1284355835
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Release files / rename_lock-0.1.4-py3-none-any.whl

Download URL rename_lock-0.1.4-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e93682d24d841ed79fd965ef3506219a3142d3af445dbc534b17d502bd0f05f
BLAKE2b-256 checksum
How to use checksums
5935131d6a8fc181bbd3106f72439cd3c438e480e935aae6e93bc6657f78a192
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Security for rename-lock 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page