A utility module to track and limit the number of running application instances by checking processes and lock files.
Project description
🚀 Instance Checker
A simple and powerful Python utility to count running instances of an application by checking both:
- Running processes (via
psutil) - Lock files in a specified directory
Perfect for preventing multiple concurrent runs of the same app.
📦 Features
✅ Count processes by command line
✅ Count lock files with .lock. pattern
✅ Works on Unix and Windows
✅ Easy to integrate into your project
✅ 100% Pythonic 😍
🧰 Installation
pip install instance-checker
⚠️ This package requires Python 3.9+
🧪 Usage Example
from instance_checker.utils import CountHelper
helper = CountHelper(lock_dir="/tmp/my_app_locks")
print(helper.process_count("my_app")) #> 2
print(helper.pid_file_count("my_app")) #> 1
🛠 How It Works
Process Checking ✅
Counts how many running processes have a given identifier in their command-line arguments.
CountHelper.process_count("my_app")
Lock File Checking 🔐
Counts how many .lock. files exist in the specified directory that contain the identifier.
helper.pid_file_count("my_app")
🧹 Why You Should Use This
- Prevents race conditions when running apps concurrently
- Lightweight and easy to integrate
- No need to write boilerplate process/lock management code
- Safe and reliable thanks to
psutilandpathlib
🧾 License
This project is licensed under the MIT License - see the LICENSE file for details.
🧑💻 Made with ❤️ by @dkurchigin
If you like this tool, give it a star ⭐ — it really helps! And if you're building cool stuff with it, let me know — I'd love to see it! 💻✨
🐙 GITVERSE
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instance_checker-0.3.0.tar.gz.
File metadata
- Download URL: instance_checker-0.3.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.9 CPython/3.13.5 Linux/6.14.0-29-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c30a7ade4b397f211b963039112904b8fd0b9e145f5195ad4fcd98310f1780a
|
|
| MD5 |
009f08052e2ae1893cc91550e1baaff9
|
|
| BLAKE2b-256 |
342f0462c50781a714ad526a0f4202c97fbe44fac1e00385171128c68708e6bb
|
File details
Details for the file instance_checker-0.3.0-py3-none-any.whl.
File metadata
- Download URL: instance_checker-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.9 CPython/3.13.5 Linux/6.14.0-29-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d976326b7fc49bae3e51dc761846c7a5c449c5146d6132c2092c36a40e49292
|
|
| MD5 |
223d734a1de5ea74d8a36bab784d0751
|
|
| BLAKE2b-256 |
01f4636631d9c953d88f2f9acd9b7897774f414a6f85e4445b06bbd076d909e7
|