nti.site.runner module

Helpers for running jobs in specific sites.

nti.site.runner.get_possible_site_names(*args, **kwargs)[source]

Helper to find the most applicable site names.

This uses the ITransactionSiteNames utility.

nti.site.runner.run_job_in_site(func, retries=0, sleep=None, site_names=<object object>, job_name=None, side_effect_free=False, root_folder_name=u'nti.dataserver')[source]

Runs the function given in func in a transaction and application local site manager (defaulting to the current site manager).

Parameters:
  • func (function) – A function of zero parameters to run. If it has a docstring, that will be used as the transactions note. A transaction will be begun before this function executes, and committed after the function completes. This function may be rerun if retries are requested, so it should be prepared for that.
  • retries (int) – The number of times to retry the transaction and execution of func if transaction.interfaces.TransientError is raised when committing. Defaults to zero (so the job runs once). If you specify None, an implementation-specific number of retries will be used.
  • sleep (float) – If not none, then the greenlet running this function will sleep for this long between retry attempts.
  • site_names – DEPRECATED. Sequence of strings giving the virtual host names to use. If you do not provide this argument, then the currently installed site will be maintained when the transaction is run. NOTE: The implementation of this may maintain either the site names or the actual site object.
  • side_effect_free (bool) – If true (not the default), then the function is assummed to have no side effects that need to be committed; the transaction runner is free to abort/rollback or commit the transaction at its leisure.
  • root_folder_name (str) – This names the folder that can be found in the root of the ZODB that will serve as the starting point to look for the persistent named site.
Returns:

The value returned by the first successful invocation of func.