Skip to content

Commit

Permalink
docs: add missing task max_failures/invocations docs (#484)
Browse files Browse the repository at this point in the history
* Update tasks.py

* Update loaders.py

* Update client.py

* Create 484.documentation.md

* nox pipeline

* british english

* Update 484.documentation.md

Co-authored-by: nulldomain <[email protected]>

* Update client.py

Co-authored-by: nulldomain <[email protected]>

* Update loaders.py

Co-authored-by: nulldomain <[email protected]>

* Update tasks.py

Co-authored-by: nulldomain <[email protected]>

---------

Co-authored-by: nulldomain <[email protected]>
  • Loading branch information
syncblaze and null-domain authored Nov 6, 2024
1 parent ae8bb1e commit 67e97ba
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions fragments/484.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document the behaviour of `max_failures` and `max_invocations` in tasks and how to disable each.
3 changes: 3 additions & 0 deletions lightbulb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ def task( # noqa: D417
the client upon the client being started, the task will also be started; it will also be started
if being added to an already-started client.
max_failures: The maximum number of failed attempts to execute the task before it is cancelled.
Setting this to a negative number will prevent the task from being cancelled, regardless of
how often the task fails.
max_invocations: The maximum number of times the task can be invoked before being stopped.
Setting this to a negative number will disable this behaviour, allowing unlimited invocations.
Note:
This method can also be called with an existing task object to register it directly.
Expand Down
3 changes: 3 additions & 0 deletions lightbulb/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,10 @@ def task(
the client upon the client being started, the task will also be started; it will also be started
if being added to an already-started client.
max_failures: The maximum number of failed attempts to execute the task before it is cancelled.
Setting this to a negative number will prevent the task from being cancelled, regardless of
how often the task fails.
max_invocations: The maximum number of times the task can be invoked before being stopped.
Setting this to a negative number will disable this behaviour, allowing unlimited invocations.
Example:
Expand Down
3 changes: 3 additions & 0 deletions lightbulb/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ class Task:
the client upon the client being started, the task will also be started; it will also be started
if being added to an already-started client.
max_failures: The maximum number of failed attempts to execute the task before it is cancelled.
Setting this to a negative number will prevent the task from being cancelled, regardless of
how often the task fails.
max_invocations: The maximum number of times the task can be invoked before being stopped.
Setting this to a negative number will disable this behaviour, allowing unlimited invocations.
"""

__slots__ = [
Expand Down

0 comments on commit 67e97ba

Please sign in to comment.