We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An instance of the JobManager class is not thread-safe. This can lead to race conditions, deadlocks, etc.
JobManager
We can do this by making using of the threading module in Python. From there, we would add a lock variable to the JobManager class:
threading
class JobManager: def __init__(self, file_path: str = DEFAULT_FILE_PATH): self.file_path = file_path self.lock = threading.Lock() self._load_jobs()
And any time we save, add, remove, etc. jobs, we want to use the with construct to invoke and use the lock. For instance:
with
def remove_job(self, job_id: str): """Removes a job by its ID.""" with self.lock: self.jobs = [job for job in self.jobs if job["id"] != job_id] self._save_jobs()
etc.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
An instance of the
JobManager
class is not thread-safe. This can lead to race conditions, deadlocks, etc.We can do this by making using of the
threading
module in Python. From there, we would add a lock variable to theJobManager
class:And any time we save, add, remove, etc. jobs, we want to use the
with
construct to invoke and use the lock. For instance:etc.
The text was updated successfully, but these errors were encountered: