Adjust the behavior of the cancel action

For pending and waiting jobs this should set the cancel status
immediately. For running jobs it should just set the cancel flag and let
the running job set the cancelled status itself during its cancelation
procedure.  This also prevents a race condition where the task manager
will start dependent jobs before realizing the status is cancelled.
This commit is contained in:
Matthew Jones 2015-01-23 10:16:54 -05:00
parent cdd61d5b9f
commit ea8537ac71

View File

@ -783,8 +783,11 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
if self.can_cancel:
if not self.cancel_flag:
self.cancel_flag = True
self.status = 'canceled'
self.save(update_fields=['cancel_flag', 'status'])
cancel_fields = ['cancel_flag']
if self.status in ('pending', 'waiting'):
self.status = 'canceled'
cancel_fields.append('status')
self.save(update_fields=cancel_fields)
self.socketio_emit_status("canceled")
if settings.BROKER_URL.startswith('amqp://'):
self._force_cancel()