def dequeue(self):
        """Dequeues the front-most job from this queue.

        Returns a Job instance, which can be executed or inspected.
        Does not respect serial queue locks
        """
        with transaction.commit_on_success(using=self.connection):
            try:
                job = Job.objects.using(self.connection).select_for_update().filter(
                queue=self, status=Job.QUEUED,
                scheduled_for__lte=now()).order_by('scheduled_for')[0]
                job.queue = None
                job.save()
            except __HOLE__:
                job = None
        if job and job.repeat:
            self.enqueue_next(job)

        return job
dataset/ETHPy150Open bretth/django-pq/pq/queue.py/Queue.dequeue