benchling_sdk.services.v2.stable.task_service module

class TaskService

Bases: benchling_sdk.services.v2.base_service.BaseService

Tasks.

Endpoints that perform expensive computations launch long-running tasks. These endpoints return the task ID (a UUID) in the response body.

After launching a task, periodically invoke the Get a task endpoint with the task UUID (e.g., every 10 seconds), until the status is no longer RUNNING.

You can access a task for up to 30 minutes after its completion, after which its data will no longer be available.

See https://benchling.com/api/reference#/Tasks

get_by_id(task_id: str) AsyncTask

Get a Task by ID.

See https://benchling.com/api/reference#/Tasks/getTask

wait_for_task(task_id: str, interval_wait_seconds: int = 1, max_wait_seconds: int = 30) AsyncTask

Wait for a task until completion or timeout.

A blocking method which polls the Benchling API and will return an AsyncTask as soon as its status is not RUNNING (in progress). This does not guarantee that the task was successful, only that Benchling has finished executing it.

If max_wait_seconds is exceeded, will raise benchling_sdk.errors.WaitForTaskExpiredError

Parameters
  • task_id – The ID of the task to poll

  • interval_wait_seconds – time to wait between API calls in seconds

  • max_wait_seconds – maximum wait time in seconds before raising WaitForTaskExpiredError

Returns

The completed AsyncTask. Check status for success or failure

Return type

AsyncTask