Skip to content

Commit f384061

Browse files
committed
hmm
1 parent fb4fcc8 commit f384061

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

services/storage/src/simcore_service_storage/modules/celery/_common.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import ssl
3+
from typing import Any
34

45
from celery import Celery # type: ignore[import-untyped]
56
from settings_library.celery import CelerySettings
@@ -8,24 +9,28 @@
89
_logger = logging.getLogger(__name__)
910

1011

12+
def _celery_configure(celery_settings: CelerySettings) -> dict[str, Any]:
13+
base_config = {
14+
"broker_connection_retry_on_startup": True,
15+
"result_expires": celery_settings.CELERY_RESULT_EXPIRES,
16+
"result_extended": True,
17+
"result_serializer": "json",
18+
"task_send_sent_event": True,
19+
"task_track_started": True,
20+
"worker_send_task_events": True,
21+
}
22+
if celery_settings.CELERY_REDIS_RESULT_BACKEND.REDIS_SECURE:
23+
base_config["redis_backend_use_ssl"] = {"ssl_cert_reqs": ssl.CERT_NONE}
24+
return base_config
25+
26+
1127
def create_app(celery_settings: CelerySettings) -> Celery:
1228
assert celery_settings
1329

14-
app = Celery(
30+
return Celery(
1531
broker=celery_settings.CELERY_RABBIT_BROKER.dsn,
1632
backend=celery_settings.CELERY_REDIS_RESULT_BACKEND.build_redis_dsn(
1733
RedisDatabase.CELERY_TASKS,
1834
),
35+
**_celery_configure(celery_settings),
1936
)
20-
app.conf.broker_connection_retry_on_startup = True
21-
# NOTE: disable SSL cert validation (https://github.com/ITISFoundation/osparc-simcore/pull/7407)
22-
if celery_settings.CELERY_REDIS_RESULT_BACKEND.REDIS_SECURE:
23-
app.conf.redis_backend_use_ssl = {"ssl_cert_reqs": ssl.CERT_NONE}
24-
app.conf.result_expires = celery_settings.CELERY_RESULT_EXPIRES
25-
app.conf.result_extended = True # original args are included in the results
26-
app.conf.result_serializer = "json"
27-
app.conf.task_send_sent_event = True
28-
app.conf.task_track_started = True
29-
app.conf.worker_send_task_events = True # enable tasks monitoring
30-
31-
return app

services/storage/tests/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,10 +976,11 @@ def celery_config() -> dict[str, Any]:
976976
def mock_celery_app(mocker: MockFixture, celery_config: dict[str, Any]) -> None:
977977
celery_app = Celery(**celery_config)
978978

979-
mocker.patch(
979+
for module in (
980+
"simcore_service_storage.modules.celery._common.create_app",
980981
"simcore_service_storage.modules.celery.create_app",
981-
return_value=celery_app,
982-
)
982+
):
983+
mocker.patch(module, return_value=celery_app)
983984

984985

985986
@pytest.fixture

0 commit comments

Comments
 (0)