Skip to content

Commit f3cadf4

Browse files
committed
Fix circular import
1 parent 74ca0e3 commit f3cadf4

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/common/core/main.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import contextlib
22
import logging
33
import os
4+
import shutil
45
import sys
56
import typing
67

@@ -10,7 +11,6 @@
1011

1112
from common.core.cli import healthcheck
1213
from common.core.constants import DEFAULT_PROMETHEUS_MULTIPROC_DIR
13-
from task_processor.utils import clear_subdirs
1414

1515
logger = logging.getLogger(__name__)
1616

@@ -50,7 +50,7 @@ def ensure_cli_env() -> typing.Generator[None, None, None]:
5050
)
5151

5252
if os.path.exists(prometheus_multiproc_dir_name):
53-
clear_subdirs(prometheus_multiproc_dir_name)
53+
_clear_subdirs(prometheus_multiproc_dir_name)
5454

5555
logger.info(
5656
"Re-created %s for Prometheus multi-process mode",
@@ -104,3 +104,13 @@ def main(argv: list[str] = sys.argv) -> None:
104104
with ensure_cli_env():
105105
# Run own commands and Django
106106
execute_from_command_line(argv)
107+
108+
109+
def _clear_subdirs(dir_path: str) -> None:
110+
for filename in os.listdir(dir_path):
111+
file_path = os.path.join(dir_path, filename)
112+
try:
113+
if os.path.isdir(file_path):
114+
shutil.rmtree(file_path)
115+
except Exception as e:
116+
logger.info(f"Failed to delete {file_path}. Reason: {e}")

src/task_processor/utils.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import argparse
22
import inspect
33
import logging
4-
import os
5-
import shutil
64
from contextlib import contextmanager
75
from typing import Any, Generator
86

@@ -71,13 +69,3 @@ def start_task_processor(
7169
yield coordinator
7270
finally:
7371
coordinator.stop()
74-
75-
76-
def clear_subdirs(dir_path: str) -> None:
77-
for filename in os.listdir(dir_path):
78-
file_path = os.path.join(dir_path, filename)
79-
try:
80-
if os.path.isdir(file_path):
81-
shutil.rmtree(file_path)
82-
except Exception as e:
83-
logger.info(f"Failed to delete {file_path}. Reason: {e}")

0 commit comments

Comments
 (0)