|
|
|
@ -5,10 +5,12 @@ import time
|
|
|
|
|
|
|
|
|
|
from celery import shared_task |
|
|
|
|
from django.core.cache import cache |
|
|
|
|
from django.db.utils import ProgrammingError |
|
|
|
|
|
|
|
|
|
from .models import Session |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ASSETS_CACHE_KEY = "terminal__session__assets" |
|
|
|
|
USERS_CACHE_KEY = "terminal__session__users" |
|
|
|
|
SYSTEM_USER_CACHE_KEY = "terminal__session__system_users" |
|
|
|
@ -36,6 +38,7 @@ def get_session_system_user_list():
|
|
|
|
|
|
|
|
|
|
def set_cache(): |
|
|
|
|
while True: |
|
|
|
|
try: |
|
|
|
|
assets = get_session_asset_list() |
|
|
|
|
users = get_session_user_list() |
|
|
|
|
system_users = get_session_system_user_list() |
|
|
|
@ -43,6 +46,9 @@ def set_cache():
|
|
|
|
|
cache.set(ASSETS_CACHE_KEY, assets) |
|
|
|
|
cache.set(USERS_CACHE_KEY, users) |
|
|
|
|
cache.set(SYSTEM_USER_CACHE_KEY, system_users) |
|
|
|
|
except ProgrammingError: |
|
|
|
|
pass |
|
|
|
|
finally: |
|
|
|
|
time.sleep(10) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -59,4 +65,5 @@ def main():
|
|
|
|
|
t.start() |
|
|
|
|
RUNNING = True |
|
|
|
|
|
|
|
|
|
# Todo: 不能migrations了 |
|
|
|
|
main() |
|
|
|
|