Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vishesh10 committed Dec 11, 2023
1 parent 94eba11 commit b5d0ffe
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
5 changes: 5 additions & 0 deletions tasktiger/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
from .task import Task
from .tasktiger import TaskTiger

# Constants pertaining to Redis keys
TASK = "task"
EXECUTIONS = "executions"
EXECUTIONS_COUNT = "executions_count"

# Task states (represented by different queues)
# Note some client code may rely on the string values (e.g. get_queue_stats).
QUEUED = "queued"
Expand Down
11 changes: 0 additions & 11 deletions tasktiger/constants.py

This file was deleted.

2 changes: 1 addition & 1 deletion tasktiger/migrations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING

from .constants import EXECUTIONS, TASK
from ._internal import EXECUTIONS, TASK
from .utils import redis_glob_escape

if TYPE_CHECKING:
Expand Down
11 changes: 9 additions & 2 deletions tasktiger/redis_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@

from redis import Redis

from ._internal import ACTIVE, ERROR, QUEUED, SCHEDULED
from .constants import EXECUTIONS, EXECUTIONS_COUNT, TASK
from ._internal import (
ACTIVE,
ERROR,
EXECUTIONS,
EXECUTIONS_COUNT,
QUEUED,
SCHEDULED,
TASK,
)

try:
from redis.commands.core import Script
Expand Down
4 changes: 3 additions & 1 deletion tasktiger/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@

from ._internal import (
ERROR,
EXECUTIONS,
EXECUTIONS_COUNT,
QUEUED,
SCHEDULED,
TASK,
g,
gen_id,
gen_unique_id,
Expand All @@ -30,7 +33,6 @@
serialize_func_name,
serialize_retry_method,
)
from .constants import EXECUTIONS, EXECUTIONS_COUNT, TASK
from .exceptions import QueueFullException, TaskImportError, TaskNotFound
from .runner import BaseRunner, get_runner_class
from .types import RetryStrategy
Expand Down
4 changes: 3 additions & 1 deletion tasktiger/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
from ._internal import (
ACTIVE,
ERROR,
EXECUTIONS,
EXECUTIONS_COUNT,
QUEUED,
SCHEDULED,
TASK,
dotted_parts,
g,
g_fork_lock,
Expand All @@ -47,7 +50,6 @@
serialize_func_name,
serialize_retry_method,
)
from .constants import EXECUTIONS, EXECUTIONS_COUNT, TASK
from .exceptions import (
RetryException,
StopRetry,
Expand Down

0 comments on commit b5d0ffe

Please sign in to comment.