Knowing if a program is already running can be useful in many situations. For example
- avoid running operations that do not expect to be executed twice or more simultaneously
- improve the usability of a software so that the user does not end up having multiple instances of the same program open at once.
runstatus is a cross-platform python library that will help you in detecting if your program was yet up and running.
It is trivial to use:
import runstatus
if runstatus.already_running('myAppName'):
print('do something, e.g. exiting')
exit(0)
The library comes with these functions:
-
already_running(codeName)detects if this same program is running in a different process
-
get_system_start_time()get the time at which the computer was turned on in unixtime
-
process_exists(pid)check if a process with that id is running
-
process_kill(pid)if a process with that id exists, kills it
Install
Either useor download the sources and run
pip install runstatuspython setup.py installNo dependencies are required. Run on python 2.7 or 3.x
Download
The git repository is available at https://github.com/riquito/runstatus
OS supported
Currently works on Linux, BSD, Windows, Mac OS
License
runstatus is licensed under the Apache License (see LICENSE file)