Example #1
0
def schedule(function,
             args=None,
             kwargs=None,
             priority=5,
             run_after=None,
             group=None,
             meta=None):
    """Schedule a tast for execution.
    """
    # Too many arguments
    # pylint: disable=R0913
    if group:
        if type(group) == Group:
            expected_group = group
        else:
            expected_group = Group.latest_group_by_reference(group)
    else:
        expected_group = None
    job = Job(name=full_name(function),
              args=dumps(args or []),
              kwargs=dumps(kwargs or {}),
              meta=dumps(meta or {}),
              scheduled=run_after,
              priority=priority,
              group=expected_group)
    job.save()
    return job
Example #2
0
def deschedule(function, args=None, kwargs=None):
    """Remove any instances of the job from the queue.
    """
    job = Job(
        name=full_name(function),
            args=dumps(args or []), kwargs=dumps(kwargs or {}))
    mark_cancelled = Job.objects.filter(executed=None,
        identity=sha1(unicode(job)).hexdigest())
    mark_cancelled.update(cancelled=_get_now())
Example #3
0
def deschedule(function, args=None, kwargs=None):
    """Remove any instances of the job from the queue.
    """
    job = Job(name=full_name(function),
              args=dumps(args or []),
              kwargs=dumps(kwargs or {}))
    mark_executed = Job.objects.filter(executed=None,
                                       identity=sha1(unicode(job)).hexdigest())
    mark_executed.update(executed=datetime.now())
Example #4
0
def schedule(function, args=None, kwargs=None, run_after=None, meta=None):
    """Schedule a tast for execution.
    """
    job = Job(name=full_name(function),
              args=dumps(args or []),
              kwargs=dumps(kwargs or {}),
              meta=dumps(meta or {}),
              scheduled=run_after)
    job.save()
    return job
Example #5
0
def schedule(function, args = None, kwargs = None,
        run_after= None, meta = None):
    """Schedule a tast for execution.
    """
    job = Job(
        name=full_name(function),
            args=dumps(args or []), kwargs=dumps(kwargs or {}),
        meta=dumps(meta or {}), scheduled=run_after)
    job.save()
    return job
Example #6
0
def schedule(function, args = None, kwargs = None,
        priority = 5, run_after= None, meta = None):
    """Schedule a tast for execution.
    """
    # Too many arguments
    # pylint: disable=R0913
    job = Job(
        name=full_name(function),
            args=dumps(args or []), kwargs=dumps(kwargs or {}),
        meta=dumps(meta or {}), scheduled=run_after,
        priority=priority)
    job.save()
    return job
Example #7
0
def deschedule(function, args=None, kwargs=None):
    """Remove any instances of the job from the queue.
    """
    job = Job(name=full_name(function),
              args=dumps(args or []),
              kwargs=dumps(kwargs or {}))
    try:
        mark_cancelled = Job.objects.filter(executed=None,
                                            identity=sha1(
                                                unicode(job)).hexdigest())
    except NameError:
        mark_cancelled = Job.objects.filter(
            executed=None, identity=sha1(str(job).encode('utf-8')).hexdigest())
    mark_cancelled.update(cancelled=_get_now())
Example #8
0
def schedule(function,
             args=None,
             kwargs=None,
             priority=5,
             run_after=None,
             meta=None):
    """Schedule a tast for execution.
    """
    # Too many arguments
    # pylint: disable=R0913
    job = Job(name=full_name(function),
              args=dumps(args or []),
              kwargs=dumps(kwargs or {}),
              meta=dumps(meta or {}),
              scheduled=run_after,
              priority=priority)
    job.save()
    return job
Example #9
0
def schedule(function, args=None, kwargs=None,
        priority=5, run_after=None, group=None, meta=None):
    """Schedule a tast for execution.
    """
    # Too many arguments
    # pylint: disable=R0913
    if group:
        if isinstance(group, Group):
            expected_group = group
        else:
            expected_group = Group.latest_group_by_reference(group)
    else:
        expected_group = None
    job = Job(
        name=full_name(function),
            args=dumps(args or []), kwargs=dumps(kwargs or {}),
        meta=dumps(meta or {}), scheduled=run_after,
        priority=priority,
        group=expected_group)
    job.save()
    return job