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(initial_wait=1, max_wait=10, backoff=1.5)
Wait for the task to finish.
Parameters
Name | Type | Description | Default |
---|---|---|---|
initial_wait | int | Initial wait time in seconds. First API request will use this as the wait parameter. | 1 |
max_wait | int | Maximum wait time in seconds between polling requests. | 10 |
backoff | float | Backoff multiplier for increasing wait times. | 1.5 |
Examples
>>> task.wait_for()
None
Notes
This method implements an exponential backoff strategy to reduce the number of API calls while waiting for long-running tasks. The first request uses the initial_wait value, and subsequent requests increase the wait time by the backoff factor, up to max_wait. To disable exponential backoff, set backoff to 1.0.
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 |