automated_task_monitor/test_program/main.py

18 lines
425 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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("程序已停止")