Skip to content

Commit 6747133

Browse files
author
Andrei Neagu
committed
reverted changes
1 parent 3095ba6 commit 6747133

File tree

5 files changed

+19
-73
lines changed

5 files changed

+19
-73
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222

2323
_logger = logging.getLogger(__name__)
2424

25-
_RPC_MAX_CANCELLATION_TIMEOUT: Final[PositiveInt] = int(
26-
timedelta(hours=1).total_seconds()
27-
)
2825
_RPC_TIMEOUT_SHORT_REQUESTS: Final[PositiveInt] = int(
2926
timedelta(seconds=20).total_seconds()
3027
)
@@ -141,14 +138,14 @@ async def remove_task(
141138
cancellation_timeout: timedelta | None,
142139
) -> None:
143140
timeout_s = (
144-
_RPC_MAX_CANCELLATION_TIMEOUT
141+
None
145142
if cancellation_timeout is None
146143
else int(cancellation_timeout.total_seconds())
147144
)
148145

149146
# NOTE: task always gets cancelled even if not waiting for it
150147
# request will return immediatlye, no need to wait so much
151-
if not wait_for_removal:
148+
if wait_for_removal is False:
152149
timeout_s = _RPC_TIMEOUT_SHORT_REQUESTS
153150

154151
result = await rabbitmq_rpc_client.request(

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,7 @@ async def remove_task(
109109
) -> None:
110110
"""cancels and removes a task
111111
112-
Arguments:
113-
wait_for_removal -- if True, then it will wait for the task to be removed
114-
before returning otherwise returns immediately
115-
116-
Keyword Arguments:
117-
cancellation_timeout (default: {None}) -- if specified it's the amount of
118-
time to wait before cancellation is timedout
119-
if not specified and:
120-
- wait_for_removal is True, it's set to _RPC_TIMEOUT_SHORT_REQUESTS
121-
- wait_for_removal is False it's set to _RPC_MAX_CANCELLATION_TIMEOUT
112+
When `wait_for_removal` is True, `cancellationt_timeout` is set to _RPC_TIMEOUT_SHORT_REQUESTS
122113
"""
123114
await _lrt_client.remove_task(
124115
rabbitmq_rpc_client,

packages/service-library/tests/aiohttp/long_running_tasks/test_long_running_tasks.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,10 @@ async def test_cancel_task(
194194
assert not data
195195
assert not error
196196

197-
# it should eventually go away, so no status
198-
# does not wait for removal any longer
199-
async for attempt in AsyncRetrying(
200-
wait=wait_fixed(0.1),
201-
stop=stop_after_delay(5),
202-
reraise=True,
203-
retry=retry_if_exception_type(AssertionError),
204-
):
205-
with attempt:
206-
status_url = client.app.router["get_task_status"].url_for(task_id=task_id)
207-
result = await client.get(f"{status_url}")
208-
await assert_status(result, status.HTTP_404_NOT_FOUND)
197+
# it should be gone, so no status
198+
status_url = client.app.router["get_task_status"].url_for(task_id=task_id)
199+
result = await client.get(f"{status_url}")
200+
await assert_status(result, status.HTTP_404_NOT_FOUND)
209201
# and also no results
210202
result_url = client.app.router["get_task_result"].url_for(task_id=task_id)
211203
result = await client.get(f"{result_url}")

packages/service-library/tests/aiohttp/long_running_tasks/test_long_running_tasks_client.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
from servicelib.aiohttp.rest_middlewares import append_rest_middlewares
1818
from settings_library.rabbit import RabbitSettings
1919
from settings_library.redis import RedisSettings
20-
from tenacity import (
21-
AsyncRetrying,
22-
retry_if_exception_type,
23-
stop_after_delay,
24-
wait_fixed,
25-
)
2620
from yarl import URL
2721

2822
pytest_simcore_core_services_selection = [
@@ -118,20 +112,12 @@ async def test_long_running_task_request_timeout(
118112
):
119113
print(f"<-- received {task=}")
120114

121-
# does not wait for removal any longer
122-
async for attempt in AsyncRetrying(
123-
wait=wait_fixed(0.1),
124-
stop=stop_after_delay(5),
125-
reraise=True,
126-
retry=retry_if_exception_type(AssertionError),
127-
):
128-
with attempt:
129-
# check the task was properly aborted by the client
130-
list_url = client.app.router["list_tasks"].url_for()
131-
result = await client.get(f"{list_url}")
132-
data, error = await assert_status(result, status.HTTP_200_OK)
133-
assert not error
134-
assert data == []
115+
# check the task was properly aborted by the client
116+
list_url = client.app.router["list_tasks"].url_for()
117+
result = await client.get(f"{list_url}")
118+
data, error = await assert_status(result, status.HTTP_200_OK)
119+
assert not error
120+
assert data == []
135121

136122

137123
async def test_long_running_task_request_error(

packages/service-library/tests/aiohttp/long_running_tasks/test_long_running_tasks_with_task_context.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
from servicelib.long_running_tasks.task import TaskContext
3030
from settings_library.rabbit import RabbitSettings
3131
from settings_library.redis import RedisSettings
32-
from tenacity.asyncio import AsyncRetrying
33-
from tenacity.retry import retry_if_exception_type
34-
from tenacity.stop import stop_after_delay
35-
from tenacity.wait import wait_fixed
3632

3733
pytest_simcore_core_services_selection = [
3834
"rabbit",
@@ -180,31 +176,15 @@ async def test_cancel_task(
180176
task_id=task_id
181177
)
182178
# calling cancel without task context should find nothing
183-
# no longer waits for removal to end
184-
async for attempt in AsyncRetrying(
185-
wait=wait_fixed(0.1),
186-
stop=stop_after_delay(5),
187-
reraise=True,
188-
retry=retry_if_exception_type(AssertionError),
189-
):
190-
with attempt:
191-
resp = await client_with_task_context.delete(f"{cancel_url}")
192-
await assert_status(resp, status.HTTP_404_NOT_FOUND)
179+
resp = await client_with_task_context.delete(f"{cancel_url}")
180+
await assert_status(resp, status.HTTP_404_NOT_FOUND)
193181
# calling with context should find and delete the task
194182
resp = await client_with_task_context.delete(
195183
f"{cancel_url.update_query(task_context)}"
196184
)
197185
await assert_status(resp, status.HTTP_204_NO_CONTENT)
198186
# calling with context a second time should find nothing
199-
# no longer waits for removal to end
200-
async for attempt in AsyncRetrying(
201-
wait=wait_fixed(0.1),
202-
stop=stop_after_delay(5),
203-
reraise=True,
204-
retry=retry_if_exception_type(AssertionError),
205-
):
206-
with attempt:
207-
resp = await client_with_task_context.delete(
208-
f"{cancel_url.update_query(task_context)}"
209-
)
210-
await assert_status(resp, status.HTTP_404_NOT_FOUND)
187+
resp = await client_with_task_context.delete(
188+
f"{cancel_url.update_query(task_context)}"
189+
)
190+
await assert_status(resp, status.HTTP_404_NOT_FOUND)

0 commit comments

Comments
 (0)