From 4981e45952307ffe159a767a87492f6499b3851e Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:52:25 +0100 Subject: [PATCH] Let the job queue handle the jobs deletion Co-authored-by: mvdbeek --- lib/galaxy/managers/users.py | 6 ++---- lib/galaxy_test/api/test_users.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/managers/users.py b/lib/galaxy/managers/users.py index de51f6294016..204cfee2e585 100644 --- a/lib/galaxy/managers/users.py +++ b/lib/galaxy/managers/users.py @@ -165,13 +165,11 @@ def delete(self, user, flush=True): def _stop_all_jobs_from_user(self, user): active_jobs = self._get_all_active_jobs_from_user(user) - message = "User deleted" session = self.session() for job in active_jobs: job.mark_deleted(self.app.config.track_jobs_in_database) - with transaction(session): - session.commit() - self.app.job_manager.stop(job, message) + with transaction(session): + session.commit() def _get_all_active_jobs_from_user(self, user: User) -> List[Job]: """Get all jobs that are not ready yet and belong to the given user.""" diff --git a/lib/galaxy_test/api/test_users.py b/lib/galaxy_test/api/test_users.py index 92e3bd9994c1..da8cc8a4e981 100644 --- a/lib/galaxy_test/api/test_users.py +++ b/lib/galaxy_test/api/test_users.py @@ -164,9 +164,9 @@ def test_delete_user_cancel_all_jobs(self): # Delete user will cancel all jobs self._delete(f"users/{user_id}", admin=True) - # Get the job state again (this time as admin), it should be deleted + # Get the job state again (this time as admin), it should be deleting job_response = self._get(f"jobs/{job_id}", admin=True).json() - assert job_response["state"] == "deleted", job_response + assert job_response["state"] == "deleting", job_response @requires_new_user def test_information(self):