automated_task_monitor/test_program/main.py

18 lines
425 B
Python
Raw Normal View History

import time
import os
def light_task():
"""轻量级任务"""
count = 0
while True:
# 简单的计数和休眠
count += 1
print(f"运行次数: {count}, PID: {os.getpid()}")
time.sleep(2) # 每2秒执行一次
if __name__ == "__main__":
print(f"程序启动PID: {os.getpid()}")
try:
light_task()
except KeyboardInterrupt:
print("程序已停止")