batch_job¶
Most applications need to perform some scheduled jobs to process information. Users need to be able to monitor the functioning of those scheduled jobs.
These classes provide the means to store the result of batch jobs to enable the user to review or plan them.
- class camelot.model.batch_job.BatchJob(*args, **kwargs)[source]¶
A batch job is a long running task that is scheduled by the user or started periodically. The BatchJob objects can be used to store information on such running task so the end user can review them
- add_exception_to_message(exc_type=None, exc_val=None, exc_tb=None)[source]¶
If an exception occurs in a batch job, this method can be used to add the stack trace of an exception to the message.
If no arguments are given, sys.exc_traceback is used.
Parameters: - exc_type – type of the exception, such as in sys.exc_type
- exc_val – value of the exception, such as in sys.exc_value
- exc_tb – a traceback object, such as in sys.exc_traceback
- add_strings_to_message(strings, color=None)[source]¶
Add strings to the message of this batch job.
This method executes within it’s own transaction, to make sure the state of the session is rolled back on failure.
Parameters: - strings – a list or generator of strings
- color – the html color to be used for the strings (‘red’,
‘green’, ...), None if the color needs no change.
- classmethod create(batch_job_type=None, status='running')[source]¶
Create a new batch job object in a session of its own. This allows to flus the batch job independent from other objects, as well as to begin/end/rollback it’s session without affecting other objects.
Parameters: - batch_job_type – an instance of type camelot.model.batch_job.BatchJobType
- status – the status of the batch job
Returns: a new BatchJob object
- id¶
The primary key
- is_canceled()[source]¶
Verifies if this Batch Job is canceled. Returns True if it is. This method is thus suiteable to call inside a running batch job to verifiy if another user has canceled the running job. Create a batch job object through the create() method to make sure requesting the status does not interfer with the normal session.
This method executes within it’s own transaction, to make sure the state of the session is rolled back on failure.
Returns: True or False