Skip to content

Commit 7b26893

Browse files
author
Andrei Neagu
committed
updated docstrings
1 parent 2d7e587 commit 7b26893

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
_logger = logging.getLogger(__name__)
2424

2525
_RPC_MAX_CANCELLATION_TIMEOUT: Final[PositiveInt] = int(
26-
timedelta(minutes=60).total_seconds()
26+
timedelta(hours=1).total_seconds()
2727
)
2828
_RPC_TIMEOUT_SHORT_REQUESTS: Final[PositiveInt] = int(
2929
timedelta(seconds=20).total_seconds()
@@ -137,9 +137,9 @@ async def remove_task(
137137
*,
138138
task_context: TaskContext,
139139
task_id: TaskId,
140-
wait_for_removal: bool,
141140
reraise_errors: bool,
142-
cancellation_timeout: timedelta | None = None,
141+
wait_for_removal: bool,
142+
cancellation_timeout: timedelta | None,
143143
) -> None:
144144
timeout_s = (
145145
_RPC_MAX_CANCELLATION_TIMEOUT

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import timedelta
12
from typing import Any
23

34
from ..rabbitmq._client_rpc import RabbitMQRPCClient
@@ -104,13 +105,27 @@ async def remove_task(
104105
task_id: TaskId,
105106
*,
106107
wait_for_removal: bool,
108+
cancellation_timeout: timedelta | None = None,
107109
) -> None:
108-
"""cancels and removes the task"""
110+
"""cancels and removes a task
111+
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
122+
"""
109123
await _lrt_client.remove_task(
110124
rabbitmq_rpc_client,
111125
lrt_namespace,
112126
task_id=task_id,
113127
task_context=task_context,
114-
wait_for_removal=wait_for_removal,
115128
reraise_errors=True,
129+
wait_for_removal=wait_for_removal,
130+
cancellation_timeout=cancellation_timeout,
116131
)

0 commit comments

Comments
 (0)