reviewbot.celery¶
Celery and Review Bot worker setup and management.
Functions
|
Create the celery queues. |
Return a Celery instance. |
|
Set up cookie storage for API communication. |
|
|
Set up logging for Celery and Review Bot. |
|
Set up Review Bot and Celery. |
|
Start a worker. |
Classes
A Celery specialization for Review Bot. |
- class ReviewBotCelery[source]¶
Bases:
Celery
A Celery specialization for Review Bot.
This takes care of initializing Celery with the right options.
New in version 3.0.
- create_queues(hostname)[source]¶
Create the celery queues.
- Returns:
The queues that this worker will listen to.
- Return type:
list
ofkombu.Queue
- setup_cookies()[source]¶
Set up cookie storage for API communication.
This will ensure that the cookie directory exists and that the cookie file can be written to.
- Raises:
IOError – The cookie directories could not be created or there’s a permission error with cookie storage. The specific error will be in the exception message.
- setup_logging(instance, conf, **kwargs)[source]¶
Set up logging for Celery and Review Bot.
This will configure the log formats we want Celery to use. This differs from Celery’s defaults not just in the structure of the log entries, but also in the addition of the logger name (used to identify different tools).
- Parameters:
instance (
celery.app.base.Celery
) – The Celery instance.conf (
celery.app.utils.Settings
) – The Celery configuration.**kwargs (
dict
, unused) – Additional keyword arguments passed to the signal.
- setup_reviewbot(instance, conf, **kwargs)[source]¶
Set up Review Bot and Celery.
This will load the Review Bot configuration, store any repository state, and set up the queues for the enabled tools.
- Parameters:
instance (
celery.app.base.Celery
) – The Celery instance.conf (
celery.app.utils.Settings
) – The Celery configuration.**kwargs (
dict
, unused) – Additional keyword arguments passed to the signal.
- get_celery()[source]¶
Return a Celery instance.
This will only be constructed the first time this is called. All subsequent calls will reuse a cached instance.
New in version 3.0.
- Returns:
The Celery instance.
- Return type:
- start_worker(broker, hostname, loglevel, logfile, detach, pidfile, uid, gid, umask, concurrency, pool_cls, autoscale)[source]¶
Start a worker.
This will take in the requested arguments and start a Celery worker, running either in the current process or in a detached process.
This also takes care to patch the concurrency module, as per Celery’s requirements, and to drop privileges if needed.
New in version 3.0.
- Parameters:
broker (
unicode
) – The broker URI.hostname (
unicode
) – The local hostname Review Bot will identify with when talking to the broker.loglevel (
unicode
) – The minimum log level.logfile (
unicode
) – The path to a log file to write to.detach (
bool
) – Whether to run the worker in a detached process.pidfile (
unicode
) – The path to a PID file to write to when detaching.uid (
unicode
) – The user ID to use when detaching.gid (
unicode
) – The group ID to use when detaching.umask (
unicode
) – The umask (in octal string format) to use for the process when detaching.concurrency (
int
) – The number of concurrent processes to run.pool_cls (
unicode
) – The pool implementation.autoscale (
unicode
) – The autoscale settings, in the form ofmax_concurrency,min_concurrency
.
- Returns:
The worker’s exit code.
- Return type:
int