flagsmith-common 2.2.1__tar.gz → 2.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/PKG-INFO +1 -1
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/pyproject.toml +1 -1
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/main.py +8 -4
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/utils.py +47 -1
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/processor.py +16 -4
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/LICENSE +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/README.md +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/app.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/cli/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/cli/healthcheck.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/logging.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/management/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/management/commands/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/management/commands/docgen.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/management/commands/start.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/management/commands/waitfordb.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/metrics.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/middleware.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/templates/docgen-metrics.md +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/urls.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/views.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/environments/permissions.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/multivariate/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/multivariate/serializers.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/serializers.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/versioning/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/versioning/serializers.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/gunicorn/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/gunicorn/conf.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/gunicorn/constants.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/gunicorn/logging.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/gunicorn/metrics.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/gunicorn/middleware.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/gunicorn/utils.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/migrations/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/migrations/helpers/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/migrations/helpers/postgres_helpers.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/organisations/permissions.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/projects/permissions.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/prometheus/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/prometheus/utils.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/py.typed +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/test_tools/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/test_tools/plugin.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/test_tools/types.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/test_tools/utils.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/types.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/admin.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/apps.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/decorators.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/exceptions.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/health.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/managers.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/metrics.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0001_initial.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0002_healthcheckmodel.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0003_add_completed_to_task.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0004_recreate_task_indexes.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0005_update_conditional_index_conditions.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0006_auto_20230221_0802.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0007_add_is_locked.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0008_add_get_task_to_process_function.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0009_add_recurring_task_run_first_run_at.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0010_task_priority.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0011_add_priority_to_get_tasks_to_process.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0012_add_locked_at_and_timeout.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0013_add_last_picked_at.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/sql/0008_get_recurring_tasks_to_process.sql +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/sql/0008_get_tasks_to_process.sql +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/sql/0011_get_tasks_to_process.sql +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/sql/0012_get_recurringtasks_to_process.sql +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/sql/0013_get_recurringtasks_to_process.sql +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/sql/__init__.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/models.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/monitoring.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/py.typed +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/routers.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/serializers.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/task_registry.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/task_run_method.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/tasks.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/threads.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/types.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/urls.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/utils.py +0 -0
- {flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/views.py +0 -0
|
@@ -2,14 +2,15 @@ import contextlib
|
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
4
|
import sys
|
|
5
|
-
import tempfile
|
|
6
5
|
import typing
|
|
7
6
|
|
|
8
7
|
from django.core.management import (
|
|
9
8
|
execute_from_command_line as django_execute_from_command_line,
|
|
10
9
|
)
|
|
10
|
+
from environs import Env
|
|
11
11
|
|
|
12
12
|
from common.core.cli import healthcheck
|
|
13
|
+
from common.core.utils import TemporaryDirectory
|
|
13
14
|
|
|
14
15
|
logger = logging.getLogger(__name__)
|
|
15
16
|
|
|
@@ -30,6 +31,7 @@ def ensure_cli_env() -> typing.Generator[None, None, None]:
|
|
|
30
31
|
main()
|
|
31
32
|
```
|
|
32
33
|
"""
|
|
34
|
+
env = Env()
|
|
33
35
|
ctx = contextlib.ExitStack()
|
|
34
36
|
|
|
35
37
|
# TODO @khvn26 Move logging setup to here
|
|
@@ -43,9 +45,11 @@ def ensure_cli_env() -> typing.Generator[None, None, None]:
|
|
|
43
45
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.dev")
|
|
44
46
|
|
|
45
47
|
# Set up Prometheus' multiprocess mode
|
|
46
|
-
if "PROMETHEUS_MULTIPROC_DIR"
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
if not env.str("PROMETHEUS_MULTIPROC_DIR", ""):
|
|
49
|
+
delete = not env.bool("PROMETHEUS_MULTIPROC_DIR_KEEP", False)
|
|
50
|
+
prometheus_multiproc_dir_name = ctx.enter_context(
|
|
51
|
+
TemporaryDirectory(delete=delete)
|
|
52
|
+
)
|
|
49
53
|
logger.info(
|
|
50
54
|
"Created %s for Prometheus multi-process mode",
|
|
51
55
|
prometheus_multiproc_dir_name,
|
|
@@ -2,9 +2,18 @@ import json
|
|
|
2
2
|
import logging
|
|
3
3
|
import pathlib
|
|
4
4
|
import random
|
|
5
|
+
import sys
|
|
6
|
+
import tempfile
|
|
5
7
|
from functools import lru_cache
|
|
6
8
|
from itertools import cycle
|
|
7
|
-
from typing import
|
|
9
|
+
from typing import (
|
|
10
|
+
Iterator,
|
|
11
|
+
Literal,
|
|
12
|
+
NotRequired,
|
|
13
|
+
TypedDict,
|
|
14
|
+
TypeVar,
|
|
15
|
+
get_args,
|
|
16
|
+
)
|
|
8
17
|
|
|
9
18
|
from django.conf import settings
|
|
10
19
|
from django.contrib.auth import get_user_model
|
|
@@ -186,3 +195,40 @@ def using_database_replica(
|
|
|
186
195
|
return manager
|
|
187
196
|
|
|
188
197
|
return manager.db_manager(chosen_replica)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
if sys.version_info >= (3, 12):
|
|
201
|
+
# Already has the desired behavior; re-export for uniform imports.
|
|
202
|
+
TemporaryDirectory = tempfile.TemporaryDirectory
|
|
203
|
+
else:
|
|
204
|
+
import contextlib
|
|
205
|
+
from typing import ContextManager, Generator
|
|
206
|
+
|
|
207
|
+
def TemporaryDirectory(
|
|
208
|
+
suffix: str | None = None,
|
|
209
|
+
prefix: str | None = None,
|
|
210
|
+
dir: str | None = None,
|
|
211
|
+
*,
|
|
212
|
+
delete: bool = True,
|
|
213
|
+
) -> ContextManager[str]:
|
|
214
|
+
"""
|
|
215
|
+
Create a temporary directory with optional cleanup control.
|
|
216
|
+
|
|
217
|
+
This wrapper exists because Python 3.12 changed TemporaryDirectory's behavior
|
|
218
|
+
by adding a 'delete' parameter, which doesn't exist in Python 3.11. This
|
|
219
|
+
function provides a consistent API across both versions.
|
|
220
|
+
|
|
221
|
+
When delete=True, uses the stdlib's TemporaryDirectory (auto-cleanup).
|
|
222
|
+
When delete=False, creates a directory with mkdtemp that persists after
|
|
223
|
+
the context manager exits, matching Python 3.12's delete=False behavior.
|
|
224
|
+
|
|
225
|
+
See https://docs.python.org/3.12/library/tempfile.html#tempfile.TemporaryDirectory for usage details.
|
|
226
|
+
"""
|
|
227
|
+
if delete:
|
|
228
|
+
return tempfile.TemporaryDirectory(suffix, prefix, dir)
|
|
229
|
+
|
|
230
|
+
@contextlib.contextmanager
|
|
231
|
+
def _tmpdir() -> Generator[str, None, None]:
|
|
232
|
+
yield tempfile.mkdtemp(suffix, prefix, dir)
|
|
233
|
+
|
|
234
|
+
return _tmpdir()
|
|
@@ -128,12 +128,17 @@ def _run_task(
|
|
|
128
128
|
)
|
|
129
129
|
task_run: AnyTaskRun = task.task_runs.model(started_at=timezone.now(), task=task) # type: ignore[attr-defined]
|
|
130
130
|
result: str
|
|
131
|
+
executor = None
|
|
131
132
|
|
|
132
133
|
try:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
# Use explicit executor management to avoid blocking on shutdown
|
|
135
|
+
# when tasks timeout but continue running in worker threads.
|
|
136
|
+
# The default context manager behavior (wait=True) would block
|
|
137
|
+
# the TaskRunner thread indefinitely waiting for stuck workers.
|
|
138
|
+
executor = ThreadPoolExecutor(max_workers=1)
|
|
139
|
+
future = executor.submit(task.run)
|
|
140
|
+
timeout = task.timeout.total_seconds() if task.timeout else None
|
|
141
|
+
future.result(timeout=timeout) # Wait for completion or timeout
|
|
137
142
|
|
|
138
143
|
task_run.result = result = TaskResult.SUCCESS.value
|
|
139
144
|
task_run.finished_at = timezone.now()
|
|
@@ -176,6 +181,13 @@ def _run_task(
|
|
|
176
181
|
delay_until,
|
|
177
182
|
)
|
|
178
183
|
|
|
184
|
+
finally:
|
|
185
|
+
# Always shutdown the executor without waiting for worker threads.
|
|
186
|
+
# This prevents the TaskRunner thread from blocking indefinitely
|
|
187
|
+
# when a task times out but continues running in a worker thread.
|
|
188
|
+
if executor is not None:
|
|
189
|
+
executor.shutdown(wait=False)
|
|
190
|
+
|
|
179
191
|
labels = {
|
|
180
192
|
"task_identifier": task_identifier,
|
|
181
193
|
"task_type": registered_task.task_type.value.lower(),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/management/commands/__init__.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/management/commands/docgen.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/management/commands/start.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/management/commands/waitfordb.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/core/templates/docgen-metrics.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/multivariate/__init__.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/multivariate/serializers.py
RENAMED
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/versioning/__init__.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/features/versioning/serializers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/common/migrations/helpers/postgres_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/0001_initial.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.1 → flagsmith_common-2.2.3}/src/task_processor/migrations/sql/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|