wait_operation

toloka.client.TolokaClient.wait_operation | Source code

wait_operation(
self,
op: Operation,
timeout: timedelta = ...,
disable_progress: bool = False
)

Waits for the operation to complete, and return it

Parameters Description

ParametersTypeDescription
opOperation

ID of the operation.

timeouttimedelta

How long to wait. Defaults to 10 minutes.

disable_progressbool

Whether disable progress bar or enable. Defaults to False (meaning progress bar is shown).

  • Returns:

    Completed operation.

  • Return type:

    Operation

Examples:

Waiting for the pool to close can be running in the background.

pool = toloka_client.get_pool(pool_id)
while not pool.is_closed():
op = toloka_client.get_analytics(
[toloka.analytics_request.CompletionPercentagePoolAnalytics(subject_id=pool.id)]
)
op = toloka_client.wait_operation(op)
percentage = op.details['value'][0]['result']['value']
print(
f'{datetime.datetime.now().strftime("%H:%M:%S")}'
f'Pool {pool.id} - {percentage}%'
)
time.sleep(60 * minutes_to_wait)
pool = toloka_client.get_pool(pool.id)
print('Pool was closed.')
Toloka-Kit
OverviewGetting OAuth tokenQuick start
Recipes
Reference
toloka.client
toloka.async_client
toloka.autoquality [autoquality]
toloka.metrics
toloka.streaming