Skip to content

Commit 0271ba8

Browse files
author
Andrei Neagu
committed
fixed broke ntests
1 parent a190275 commit 0271ba8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

packages/service-library/src/servicelib/long_running_tasks/task.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,14 @@ async def remove_task(
385385
return
386386

387387
if tracked_task.task_id in self._created_tasks:
388-
# will have affect in the worker which deals with the removal
388+
task_to_cancel = self._created_tasks.pop(tracked_task.task_id, None)
389+
if task_to_cancel is not None:
390+
# canceling the task affects the worker that started it.
391+
# awaiting the cancelled task is a must since if the CancelledError
392+
# was intercepted, those actions need to finish
393+
await cancel_wait_task(task_to_cancel)
394+
389395
await self._tasks_data.delete_task_data(task_id)
390-
self._created_tasks.pop(tracked_task.task_id, None)
391396

392397
# wait for task to be completed
393398
async for attempt in AsyncRetrying(

services/web/server/tests/unit/with_dbs/02/test_projects_cancellations.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from servicelib.rabbitmq.rpc_interfaces.async_jobs.async_jobs import (
2828
AsyncJobComposedResult,
2929
)
30+
from settings_library.redis import RedisSettings
3031
from simcore_postgres_database.models.users import UserRole
3132
from simcore_service_webserver._meta import api_version_prefix
3233
from simcore_service_webserver.application_settings import get_application_settings
@@ -40,7 +41,9 @@
4041

4142
@pytest.fixture
4243
def app_environment(
43-
app_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch
44+
use_in_memory_redis: RedisSettings,
45+
app_environment: EnvVarsDict,
46+
monkeypatch: pytest.MonkeyPatch,
4447
) -> EnvVarsDict:
4548
envs_plugins = setenvs_from_dict(
4649
monkeypatch,
@@ -91,6 +94,7 @@ def _standard_user_role_response() -> (
9194

9295
@pytest.mark.parametrize(*_standard_user_role_response())
9396
async def test_copying_large_project_and_aborting_correctly_removes_new_project(
97+
mock_dynamic_scheduler: None,
9498
client: TestClient,
9599
logged_user: dict[str, Any],
96100
primary_group: dict[str, str],
@@ -142,6 +146,7 @@ async def test_copying_large_project_and_aborting_correctly_removes_new_project(
142146

143147
@pytest.mark.parametrize(*_standard_user_role_response())
144148
async def test_copying_large_project_and_retrieving_copy_task(
149+
mock_dynamic_scheduler: None,
145150
client: TestClient,
146151
logged_user: dict[str, Any],
147152
primary_group: dict[str, str],
@@ -296,6 +301,7 @@ async def test_copying_too_large_project_returns_422(
296301
):
297302
assert client.app
298303
app_settings = get_application_settings(client.app)
304+
assert app_settings.WEBSERVER_PROJECTS
299305
large_project_total_size = (
300306
app_settings.WEBSERVER_PROJECTS.PROJECTS_MAX_COPY_SIZE_BYTES + 1
301307
)

0 commit comments

Comments
 (0)