Link Search Menu Expand Document

WiFi Pineapple Python Job Manager Class

Table of contents

  1. Introduction
  2. Classes

Introduction

Python API

Classes

class JobManager
A job to be used with the background JobManager that installs or uninstalls dependencies.

Methods

def get_job(self, job_id: str, remove_if_complete: bool = True) -> Optional[Job]
Attempt to get a job by its id. If the job_id doesn't exist then None is returned. If `remove_if_complete` is True the job will be deleted from memory only if it is completed. This is the default behavior to prevent JobManager from tacking up unnecessary memory.

Parameters

  • job_id: The id of the job to find.
  • remove_if_complete: True to delete the job from memory after its complete. (Default: True)

Returns

  • Optional[Job]: an instance of Job if found, else None
def prune_completed_jobs(self)
Removes all completed jobs from memory.
def remove_job(self, job_id: str)
Remove a job from memory based on its id. This will remove the job regardless of its completion status.

Parameters

  • job_id: The id of the job to delete.

def execute_job(self, job: Job, callbacks: List[Callable[[Job], None]] = None) -> str
Assign an id to a job and execute it in a background thread. The id will be returned and the job can be tracked by calling `get_job` and providing it the id.

Parameters

  • job: an instance of Job to start running.
  • callbacks: An optional list of functions that take `job` as a parameter to be called when completed. These will be called regardless if `job` raises an exception or not.

Returns

  • str: The id of the running job.