parameters: (cls, cr, job_ids)
return_statement: return cr.dictfetchone()
docstring: Acquire one job for update from the job_ids tuple.
docstring_summary: Acquire one job for update from the job_ids tuple.
docstring_tokens: Acquire one job for update from the job_ids tuple .
function: def _acquire_one_job(cls, cr, job_ids):
          """ Acquire one job for update from the job_ids tuple. """
  
          # We have to make sure ALL jobs are executed ONLY ONCE no matter
          # how many cron workers may process them. The exlusion mechanism
          # is twofold: (i) prevent parallel processing of the same job,
          # and (ii) prevent re-processing jobs that have been processed
          # already.
          #
          # (i) is implemented via `LIMIT 1 FOR UPDATE SKIP LOCKED`, each
          # worker just acquire one available job at a time and lock it so
          # the other workers don't select it too.
          # (ii) is implemented via the `WHERE` statement, when a job has
          # been processed, its nextcall is updated to a date in the
          # future and the optionnal trigger is removed.
          #
          # An `UPDATE` lock type is the strongest row lock, it conflicts
          # with ALL other lock types. Among them the `KEY SHARE` row lock
          # which is implicitely aquired by foreign keys to prevent the
          # referenced record from being removed while in use. Because we
          # never delete acquired cron jobs, foreign keys are safe to
          # concurrently reference cron jobs. Hence, the `NO KEY UPDATE`
          # row lock is used, it is a weaker lock that does conflict with
          # everything BUT `KEY SHARE`.
          #
          # Learn more: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-ROWS
  
          cr.execute("""
              SELECT *
              FROM ir_cron
              WHERE active = true
                AND numbercall != 0
                AND (nextcall <= (now() at time zone 'UTC')
                  OR EXISTS (
                      SELECT cron_id
                      FROM ir_cron_trigger
                      WHERE call_at <= (now() at time zone 'UTC')
                        AND cron_id = ir_cron.id
                  )
                )
                AND id in %s
              ORDER BY priority
              LIMIT 1 FOR NO KEY UPDATE SKIP LOCKED
          """, [job_ids])
          return cr.dictfetchone()
function_tokens: def _acquire_one_job ( cls , cr , job_ids ) : # We have to make sure ALL jobs are executed ONLY ONCE no matter # how many cron workers may process them. The exlusion mechanism # is twofold: (i) prevent parallel processing of the same job, # and (ii) prevent re-processing jobs that have been processed # already. # # (i) is implemented via `LIMIT 1 FOR UPDATE SKIP LOCKED`, each # worker just acquire one available job at a time and lock it so # the other workers don't select it too. # (ii) is implemented via the `WHERE` statement, when a job has # been processed, its nextcall is updated to a date in the # future and the optionnal trigger is removed. # # An `UPDATE` lock type is the strongest row lock, it conflicts # with ALL other lock types. Among them the `KEY SHARE` row lock # which is implicitely aquired by foreign keys to prevent the # referenced record from being removed while in use. Because we # never delete acquired cron jobs, foreign keys are safe to # concurrently reference cron jobs. Hence, the `NO KEY UPDATE` # row lock is used, it is a weaker lock that does conflict with # everything BUT `KEY SHARE`. # # Learn more: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-ROWS cr . execute ( """
              SELECT *
              FROM ir_cron
              WHERE active = true
                AND numbercall != 0
                AND (nextcall <= (now() at time zone 'UTC')
                  OR EXISTS (
                      SELECT cron_id
                      FROM ir_cron_trigger
                      WHERE call_at <= (now() at time zone 'UTC')
                        AND cron_id = ir_cron.id
                  )
                )
                AND id in %s
              ORDER BY priority
              LIMIT 1 FOR NO KEY UPDATE SKIP LOCKED
          """ , [ job_ids ] ) return cr . dictfetchone ( )