Skip to content

Commit

Permalink
Let the job queue handle the jobs deletion
Browse files Browse the repository at this point in the history
Co-authored-by: mvdbeek <[email protected]>
  • Loading branch information
davelopez and mvdbeek committed Jan 31, 2024
1 parent 80aa655 commit 4981e45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lib/galaxy/managers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy_test/api/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 4981e45

Please sign in to comment.