Skip to content

Commit 9b8e39d

Browse files
committed
Added timeout to docs
1 parent 591a207 commit 9b8e39d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

arca/task.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
class Task:
1212
""" A class for defining tasks the run in the repositories. The task is defined by an entry point,
13-
arguments and keyword arguments. The class uses :class:`entrypoints.EntryPoint` to load the callables.
13+
timeout (5 seconds by default), arguments and keyword arguments.
14+
The class uses :class:`entrypoints.EntryPoint` to load the callables.
1415
As apposed to :class:`EntryPoint <entrypoints.EntryPoint>`, only objects are allowed, not modules.
1516
1617
Let's presume we have this function in a package ``library.module``:
@@ -45,6 +46,9 @@ def __init__(self, entry_point: str, *,
4546

4647
try:
4748
self._timeout = int(timeout)
49+
50+
if self._timeout < 1:
51+
raise ValueError
4852
except ValueError:
4953
raise TaskMisconfigured("Provided timeout could not be converted to int.")
5054

docs/tasks.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ set up like this:
6060
task1 = Task("test:func", args=[5], kwargs={"y": 10}) # -> 50
6161
task2 = Task("test:func", kwargs={"x": 5, "y": 10}) # -> 50 again
6262
63+
Timeout
64+
-------
65+
66+
The :class:`arca.Task` class allows for a timeout to be defined with the task with the keyword argument ``timeout``.
67+
It must be a positive integer.
68+
The default value is 5 seconds.
69+
70+
When a task exceeds a timeout, :class:`arca.exceptions.BuildTimeoutError` is raised.
71+
6372
Result
6473
------
6574

0 commit comments

Comments
 (0)