# Path: pq/exceptions.py
# class InvalidInterval(Exception):
#     pass


import importlib
import inspect
from datetime import timedelta, datetime
from dateutil.relativedelta import relativedelta, weekday
from dateutil.relativedelta import weekdays as wdays
from picklefield.fields import PickledObjectField
from django.db import models
from django.db import transaction
from django.utils.timezone import now
from six import get_method_self, integer_types
from .exceptions import InvalidInterval
            '%r is not a valid kwargs dict.' % (kwargs,)
        job = cls()
        job.connection = connection
        job.created_at = now()
        if inspect.ismethod(func):
            job.instance = get_method_self(func)
            job.func_name = func.__name__
        elif inspect.isfunction(func) or inspect.isbuiltin(func):
            job.func_name = '%s.%s' % (func.__module__, func.__name__)
        else:  # we expect a string
            job.func_name = func
        job.args = args
        job.kwargs = kwargs
        job.description = job.get_call_string()[:254]
        job.result_ttl = result_ttl
        job.status = status
        job.scheduled_for = scheduled_for
        job.interval = interval
        job.between = between
        job.repeat = repeat
        job.weekdays = weekdays
        job.clean()
        return job

    def clean(self):
        if isinstance(self.interval, int) and self.interval >= 0:
                self.interval = relativedelta(seconds=self.interval)
        elif self.scheduled_for and not (
                isinstance(self.interval, timedelta) or
                isinstance(self.interval, relativedelta)):

# Path: pq/exceptions.py
# class InvalidInterval(Exception):
#     pass


# Path: pq/job.py
import importlib
import inspect
from datetime import timedelta, datetime
from dateutil.relativedelta import relativedelta, weekday
from dateutil.relativedelta import weekdays as wdays
from picklefield.fields import PickledObjectField
from django.db import models
from django.db import transaction
from django.utils.timezone import now
from six import get_method_self, integer_types
from .exceptions import InvalidInterval

            '%r is not a valid kwargs dict.' % (kwargs,)
        job = cls()
        job.connection = connection
        job.created_at = now()
        if inspect.ismethod(func):
            job.instance = get_method_self(func)
            job.func_name = func.__name__
        elif inspect.isfunction(func) or inspect.isbuiltin(func):
            job.func_name = '%s.%s' % (func.__module__, func.__name__)
        else:  # we expect a string
            job.func_name = func
        job.args = args
        job.kwargs = kwargs
        job.description = job.get_call_string()[:254]
        job.result_ttl = result_ttl
        job.status = status
        job.scheduled_for = scheduled_for
        job.interval = interval
        job.between = between
        job.repeat = repeat
        job.weekdays = weekdays
        job.clean()
        return job

    def clean(self):
        if isinstance(self.interval, int) and self.interval >= 0:
                self.interval = relativedelta(seconds=self.interval)
        elif self.scheduled_for and not (
                isinstance(self.interval, timedelta) or
                isinstance(self.interval, relativedelta)):

            raise InvalidInterval(