<commit_before>from .job import Job
from .utils import get_backend

from . import app_settings

class task(object):
    def __init__(self, queue='default', timeout=None):
        self.queue = queue
        self.timeout = timeout

        app_settings.WORKERS.setdefault(self.queue, 1)

    def __call__(self, fn):
        return TaskWrapper(fn, self.queue, self.timeout)

class TaskWrapper(object):
    def __init__(self, fn, queue, timeout):
        self.fn = fn
        self.queue = queue
        self.timeout = timeout

        self.path = '%s.%s' % (fn.__module__, fn.__name__)

    def __repr__(self):
        return "<TaskWrapper: %s>" % self.path

    def __call__(self, *args, **kwargs):
        job = Job(self.path, args, kwargs)
        job.validate()

        get_backend().enqueue(job, self.queue)<commit_msg>Add ability to specify a specific queue when running a task.<commit_after>from .job import Job
from .utils import get_backend

from . import app_settings

class task(object):
    def __init__(self, queue='default', timeout=None):
        self.queue = queue
        self.timeout = timeout

        app_settings.WORKERS.setdefault(self.queue, 1)

    def __call__(self, fn):
        return TaskWrapper(fn, self.queue, self.timeout)

class TaskWrapper(object):
    def __init__(self, fn, queue, timeout):
        self.fn = fn
        self.queue = queue
        self.timeout = timeout

        self.path = '%s.%s' % (fn.__module__, fn.__name__)

    def __repr__(self):
        return "<TaskWrapper: %s>" % self.path

    def __call__(self, *args, **kwargs):
        # Allow us to override which queue at the last moment
        queue = kwargs.pop('queue', self.queue)

        job = Job(self.path, args, kwargs)
        job.validate()

        get_backend().enqueue(job, queue)
{'fraction_non_alphanumeric': 0.11754874651810585, 'fraction_numerical': 0.0011142061281337048, 'mean_word_length': 2.703092783505155, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1860606', 'n_tokens_mistral': 545, 'n_tokens_neox': 529, 'n_words': 150}