Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pulpcore/exceptions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,16 @@ class ReplicateError(PulpException):

def __str__(self):
return f"[{self.error_code}] " + _("Replication failed")


class TaskTimeoutError(PulpException):
"""
Raised when an immediate task took too long.
"""

error_code = "PLP0019"

def __str__(self, task, timeout):
return f"[{self.error_code}] " + _(
"Immediate task {task} timed out after {timeout} seconds."
).format(task=task, timeout=timeout)
7 changes: 2 additions & 5 deletions pulpcore/tasking/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
TASK_WAKEUP_HANDLE,
TASK_WAKEUP_UNBLOCK,
)
from pulpcore.exceptions.base import PulpException, InternalErrorException
from pulpcore.exceptions.base import PulpException, InternalErrorException, TaskTimeoutError
from pulp_glue.common.exceptions import PulpException as PulpGlueException

from pulpcore.middleware import x_task_diagnostics_var
Expand Down Expand Up @@ -223,10 +223,7 @@ async def _wrapper():
try:
return await asyncio.wait_for(coro_fn(), timeout=IMMEDIATE_TIMEOUT)
except asyncio.TimeoutError:
msg_template = "Immediate task %s timed out after %s seconds."
error_msg = msg_template % (task_pk, IMMEDIATE_TIMEOUT)
_logger.info(error_msg)
raise RuntimeError(error_msg)
raise TaskTimeoutError(task_pk, timeout=IMMEDIATE_TIMEOUT)

return _wrapper

Expand Down