Skip to main content

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 psutil and pathlib

🧾 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

🔗 https://gitverse.ru/dkurchigin/instance_checker

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

instance_checker-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

instance_checker-0.1.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file instance_checker-0.1.1.tar.gz.

File metadata

  • Download URL: instance_checker-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.9 CPython/3.13.5 Linux/6.14.0-28-generic

File hashes

Hashes for instance_checker-0.1.1.tar.gz
Algorithm Hash digest
SHA256 01b69892c2b9c250f80f5688f90f66e207e83e93420bdbb927af2d128c6884c1
MD5 581356d3b8b7025e3659b9a6a3ce9988
BLAKE2b-256 acec8958cbe7abc369b52c909ae4d51561c5c1988aa85c2bdcd6020051b069f4

See more details on using hashes here.

File details

Details for the file instance_checker-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: instance_checker-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.9 CPython/3.13.5 Linux/6.14.0-28-generic

File hashes

Hashes for instance_checker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f1a43b5d1ce69a50b673307bddd9d70dd5fb5180ff74ed1936e1fb14e41f404
MD5 9ecbacb3ef9faf7a2b66b544cf14d7b7
BLAKE2b-256 0a1647ed059c1f9d104d2d80eb48d0d18203e4605638703aa4ad4aaf8b9e6efb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page