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 | Type | Description |
---|---|---|
op | Operation | ID of the operation. |
timeout | timedelta | How long to wait. Defaults to 10 minutes. |
disable_progress | bool | Whether disable progress bar or enable. Defaults to |
Returns:
Completed operation.
Return type:
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.')