79266706

Date: 2024-12-09 23:43:22
Score: 1.5
Natty:
Report link

The self.lock.__enter__() looked suspicious without exiting, so I changed it to become the following and it rolled back as expected

        with transaction.atomic(savepoint=True):
            signals.task_started.send(sender=self.flow_class, process=self.process, task=self.task)

            self.process.save()

            lock_impl = self.flow_class.lock_impl(self.flow_class.instance)
            self.lock = lock_impl(self.flow_class, self.process.pk)
            # self.lock.__enter__()
            with self.lock:
                self.task.process = self.process
                self.task.finished = now()
                self.task.save()

                signals.task_finished.send(sender=self.flow_class, process=self.process, task=self.task)
                signals.flow_started.send(sender=self.flow_class, process=self.process, task=self.task)

                self.activate_next()

@kmmbvnr can you please verify? Is there going to be any unintended consequences after this change?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • User mentioned (1): @kmmbvnr
  • Self-answer (0.5):
  • Looks like a comment (1):
  • High reputation (-2):
Posted by: James Lin