python 定时清理django 过期 session

import time, os, sched 

schedule = sched.scheduler(time.time, time.sleep) 
    
def perform_command(cmd, inc): 
    
    schedule.enter(inc, 0, perform_command, (cmd, inc)) 
    os.system(cmd) 
        
def timming_exe(cmd, inc = 60): 
    
    schedule.enter(inc, 0, perform_command, (cmd, inc)) 
    
    schedule.run() 
        
    
print("Clear up expire session by timer") 
os.chdir('D:/workspace/busymonkey')
timming_exe("python manage.py clearsessions", 20)

你可能感兴趣的:(Python)