queue icon indicating copy to clipboard operation
queue copied to clipboard

Problem with perform_enqueued_jobs function

Open SonoDavid opened this issue 9 months ago • 2 comments

For me, the following function doesn't work as it should for queue jobs using graphs. Somehow, all of the jobs get assigned the same graph_uuid and this is why the function below does not do the sorting correctly. Also, priority field is not included in the sorting, which would also help to get the jobs sorting in the correct order.

    def perform_enqueued_jobs(self):
        """Perform the enqueued jobs synchronously"""

        def by_graph(job):
            return job.graph_uuid or ""

        sorted_jobs = sorted(self.enqueued_jobs, key=by_graph)
        self.enqueued_jobs = []
        for graph_uuid, jobs in groupby(sorted_jobs, key=by_graph):
            if graph_uuid:
                self._perform_graph_jobs(jobs)
            else:
                self._perform_single_jobs(jobs)

Can somebody explain to me where and how the graph_uuid gets assigned and why this does work for my live environment, but not in the tests?

SonoDavid avatar Jan 21 '25 12:01 SonoDavid