Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Lock script to allow only one instance

Project description

Build Status Requirements Status

Lock tool for scripts.

Package

Example

import time
import atexit

from scriptlock import Lock

lock = Lock()
atexit.register(lock.cleanup)  # Needed to clean the lock correctly

time.sleep(100)

Launch another one and see what happend

Workaround

The use of atexit is necessary to correctly clean the lock. We tried to use the del module but it caused issues with the logger.

Tests

Testing is set up using pytest and coverage is handled with the pytest-cov plugin.

Run your tests with py.test in the root directory.

Coverage is ran by default and is set in the pytest.ini file. To see an html output of coverage open htmlcov/index.html after running the tests.

TODO

Travis CI

There is a .travis.yml file that is set up to run your tests for python 2.7 and python 3.2, should you choose to use it.

TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
scriptlock-1.0.5-py2.py3-none-any.whl (4.6 kB) Copy SHA256 hash SHA256 Wheel py2.py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page