Spaces:
Running
Running
File size: 665 Bytes
947c08e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from django_thread import Thread
from time import sleep
from backend.module.utils import date_utils
import requests, environ
from core import settings
env = environ.Env()
class Delete(Thread):
def run(self):
while True:
try:
requests.post(f'{settings.WORKER_SERVED_SCOPE}/worker/session/delete_outdated/', headers={"Worker-Token": env("WORKER_TOKEN")})
print('[Worker] All expired sessions have been cleared successfully.')
sleep(1.5 * 60 * 60)
except Exception as e:
print(e)
sleep(10)
thread = Delete()
thread.daemon = True
thread.start()
|