def transition(self, key, start, finish, compute_start=None, compute_stop=None, *args, **kwargs):
    if (finish == 'processing'):
        ts = self.scheduler.tasks[key]
        self.put_key_in_stealable(ts)
    elif (start == 'processing'):
        ts = self.scheduler.tasks[key]
        self.remove_key_from_stealable(ts)
        d = self.in_flight.pop(ts, None)
        if d:
            thief = d['thief']
            victim = d['victim']
            self.in_flight_occupancy[thief] -= d['thief_duration']
            self.in_flight_occupancy[victim] += d['victim_duration']
            if (not self.in_flight):
                self.in_flight_occupancy.clear()
                self._in_flight_event.set()
def transition(self, key, start, finish, compute_start=None, compute_stop=None, *args, **kwargs):
    if (finish == 'processing'):
        ts = self.scheduler.tasks[key]
        self.put_key_in_stealable(ts)
    elif (start == 'processing'):
        ts = self.scheduler.tasks[key]
        self.remove_key_from_stealable(ts)
        d = self.in_flight.pop(ts, None)
        if d:
            thief = d['thief']
            victim = d['victim']
            self.in_flight_occupancy[thief] -= d['thief_duration']
            self.in_flight_occupancy[victim] += d['victim_duration']
            if (not self.in_flight):
                self.in_flight_occupancy.clear()
                self._in_flight_event.set()