Task Class¶
Task¶
- class es_wait.task.Task(client: Elasticsearch, pause: float = 9.0, timeout: float = 7200.0, max_exceptions: int = 10, action: Literal['forcemerge', 'reindex', 'update_by_query'] = 'reindex', task_id: str = '')¶
Bases:
WaiterWait for a task to complete
- action¶
The action to wait for
- add_exception(value: Exception) None¶
This method appends value the exceptions list.
- Parameters:
value (Exception) – An exception to add
- announce() None¶
This method is called when the Waiter class is initialized. It logs a level 1 debug message using
waitstr.
- check() bool¶
This function calls
tasks.get()with the providedtask_idand sets the values fortask_dataandtaskas part of its execution pipeline.It then calls
reindex_check()to see if it is a reindex operation.Finally, it returns whatever
task_complete()returns.- Getter:
Returns if the check was complete
- Type:
- client¶
An
Elasticsearchclient instance
- do_health_report¶
Only changes to True in certain circumstances
- property exception_count_msg: str¶
This property returns a messgage showing the current number of exceptions raised and the maximum number of exceptions allowed.
- Getter:
Returns ‘X exceptions raised out of Y allowed’
- Type:
- property exceptions: list¶
This property returns a list of exceptions raised during the wait.
- Getter:
Returns a list of exceptions raised
- Type:
- exceptions_raised¶
The number of exceptions raised
- max_exceptions¶
The maximum number of exceptions to allow
- pause¶
The delay between checks for completion
- reindex_check() None¶
Check to see if the task is a reindex operation. The task may be “complete” but had one or more failures. Raise a
ValueErrorexception if errors were encountered.
- task¶
The contents of
task_data['task']
- property task_complete: bool¶
Process
taskandtask_datato see if the task has completed, or is still running.If
task_datacontains'completed': True, then it will returnTrue. If the task is not completed, it will log some information about the task and returnFalse
- task_data¶
The
tasks.get()results
- task_id¶
The task identification string
- timeout¶
The number of seconds before giving up. -1 means no timeout.
- too_many_exceptions() None¶
If the number of exceptions raised is greater than or equal to the maximum number of exceptions allowed, then a
ExceptionCountwill be raised.
- wait(frequency: int = 5) None¶
This method is where the actual waiting occurs. Depending on what frequency is set to, you should see non-DEBUG level logs no more than every frequency seconds.
If
timeouthas been reached withoutcheck()returning asTrue, then aTimeoutErrorwill be raised.If
check()returnsFalse, then the method will waitpauseseconds before callingcheck()again.Elapsed time will be logged every frequency seconds, when
check()isTrue, or whentimeoutis reached.If
do_health_reportisTrue, then callclient.health_report()and pass the results toutils.health_report().- Parameters:
frequency – The number of seconds between log reports on progress.