18 lines
425 B
Python
18 lines
425 B
Python
![]() |
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("程序已停止")
|