handle refusal with an exception

This commit is contained in:
Mike McLean 2024-02-02 14:12:52 -05:00 committed by Tomas Kopecek
parent 4b35b7b729
commit 4a31c42edd
3 changed files with 12 additions and 3 deletions

View file

@ -1504,6 +1504,9 @@ class TaskManager(object):
except (SystemExit, koji.tasks.ServerExit, KeyboardInterrupt):
# we do not trap these
raise
except koji.tasks.RefuseTask as refuse:
self.session.host.refuseTask(handler.id, msg=str(refuse))
return
except koji.tasks.ServerRestart:
# freeing this task will allow the pending restart to take effect
self.session.host.freeTasks([handler.id])

View file

@ -110,6 +110,11 @@ class ServerRestart(Exception):
pass
class RefuseTask(Exception):
"""Raise to task handler to refuse a task"""
pass
def parse_task_params(method, params):
"""Parse task params into a dictionary