Пример #1
0
  def claimJob(self, job_key):
    """A transaction to claim a job.

    The transaction is rolled back if the status is not 'waiting'.
    """

    job = Job.get_by_id(job_key)

    if job.status != 'waiting':
      raise db.Rollback()

    job.status = 'started'

    if job.put():
      return job
    else:
      return None
Пример #2
0
  def claimJob(self, job_key):
    """A transaction to claim a job.

    The transaction is rolled back if the status is not 'waiting'.
    """

    job = Job.get_by_id(job_key)

    if job.status != 'waiting':
      raise db.Rollback()

    job.status = 'started'

    # pylint: disable-msg=E1103
    if job.put():
      return job
    else:
      return None
Пример #3
0
def deidleJobs(amount):
  """Sets jobs that are stuck in 'started' to waiting.

  Args:
    amount: the amount of jobs to deidle
  """

  from soc.models.job import Job

  query = Job.all().filter('status', 'started')
  jobs = query.fetch(amount)

  if not jobs:
    print "no idle jobs"

  for job in jobs:
     job.status = 'waiting'
     job.put()
     print "restarted %d" % job.key().id()
Пример #4
0
def deidleJobs(amount):
    """Sets jobs that are stuck in 'started' to waiting.

  Args:
    amount: the amount of jobs to deidle
  """

    from soc.models.job import Job

    query = Job.all().filter('status', 'started')
    jobs = query.fetch(amount)

    if not jobs:
        print "no idle jobs"

    for job in jobs:
        job.status = 'waiting'
        job.put()
        print "restarted %d" % job.key().id()