connect.tasks

connect.tasks

Task resources.

Classes

Name Description
Task
Tasks

Task

connect.tasks.Task(self, ctx, /, **kwargs)

Attributes

Name Description
error_code The error code.
error_message The error message.
is_finished The task state.

Methods

Name Description
update Update the task.
wait_for Wait for the task to finish.
update
connect.tasks.Task.update(*args, **kwargs)

Update the task.

See Also

task.wait_for : Wait for the task to complete.

Notes

When waiting for a task to complete, one should consider utilizing task.wait_for.

Examples
>>> task.output
[
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
]
>>> task.update()
>>> task.output
[
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
    "Pretium aenean pharetra magna ac placerat vestibulum lectus mauris."
]
wait_for
connect.tasks.Task.wait_for(wait=1, max_attempts=None)

Wait for the task to finish.

Parameters
Name Type Description Default
wait int Maximum wait time in seconds between polling requests. 1
max_attempts int | None Maximum number of polling attempts. If None, polling will continue indefinitely. None
Raises
Name Type Description
TimeoutError If the task does not finish within the maximum attempts.
Notes

If the task finishes before the wait time or maximum attempts are reached, the function will return immediately. For example, if the wait time is set to 5 seconds and the task finishes in 2 seconds, the function will return after 2 seconds.

If the task does not finished after the maximum attempts, a TimeoutError will be raised. By default, the maximum attempts is None, which means the function will wait indefinitely until the task finishes.

Examples
>>> task.wait_for()
None

Waiting for a task to finish with a custom wait time.

>>> task.wait_for(wait=5)
None

Waiting for a task with a maximum number of attempts.

>>> task.wait_for(max_attempts=3)
None

Tasks

connect.tasks.Tasks(self, ctx)

Methods

Name Description
get Get a task.
get
connect.tasks.Tasks.get(uid, **kwargs)

Get a task.

Parameters
Name Type Description Default
uid str Task identifier. required
Returns
Name Type Description
Task