23 lines
370 B
Python
23 lines
370 B
Python
import time
|
|
import os
|
|
import tempfile
|
|
import psutil
|
|
|
|
|
|
PID_FILE = os.path.join(tempfile.gettempdir(), "catfish.pid")
|
|
|
|
|
|
def is_running():
|
|
return os.path.exists(PID_FILE)
|
|
|
|
|
|
def get_running_process() -> psutil.Process:
|
|
assert is_running()
|
|
with open(PID_FILE) as f:
|
|
return psutil.Process(int(f.read()))
|
|
|
|
|
|
def main():
|
|
while True:
|
|
time.sleep(1)
|