Frappe Background Jobs


  1. Get Frappe Redis connection

    from frappe.utils.background_jobs import get_redis_conn
    get_redis_conn()

    this method returns the redis connection of the frappe and to get a new redis connection pass username and password as variables

  2. Get job for the sites

    from frappe.utils.background_jobs import get_jobs
    get_jobs(site_name, queue)

    gives all the jobs in the particular site the queue is specified it returns only the specific jobs in that queue else it returns all job

  3. Get Workers

    from frappe.utils.background_jobs import get_workers
    get_workers(queue)

    Returns a list of Worker objects tied to a queue object if queue is passed, else returns a list of all workers

  4. Start Worker

    from frappe.utils.background_jobs import start_worker
    start_worker(queue, burst = (True or False))

    Wrapper to start rq worker. Connects to redis and monitors these queues.

  5. get the list of all queue

    from frappe.utils.background_jobs import get_queue_list
    start_worker(queue, burst = (True or False))

    Defines possible queues. Also wraps a given queue in a list after validating.

  6. Get the Queue

    from frappe.utils.background_jobs import get_queue
    get_queue(queue_type)

    Returns a Queue object tied to a redis connection