optimize redis import

This commit is contained in:
harry
2024-04-10 17:47:40 +08:00
parent 2c72eb92a1
commit 740960b0ff

View File

@@ -1,7 +1,5 @@
import ast import ast
import json
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
import redis
from app.config import config from app.config import config
from app.models import const from app.models import const
@@ -47,6 +45,7 @@ class MemoryState(BaseState):
class RedisState(BaseState): class RedisState(BaseState):
def __init__(self, host='localhost', port=6379, db=0): def __init__(self, host='localhost', port=6379, db=0):
import redis
self._redis = redis.StrictRedis(host=host, port=port, db=db) self._redis = redis.StrictRedis(host=host, port=port, db=db)
def update_task(self, task_id: str, state: int = const.TASK_STATE_PROCESSING, progress: int = 0, **kwargs): def update_task(self, task_id: str, state: int = const.TASK_STATE_PROCESSING, progress: int = 0, **kwargs):