From ea9d7d176e40f70749e42f560b23b3387d1e7f3c Mon Sep 17 00:00:00 2001 From: Eduard Carreras Date: Thu, 4 Jan 2018 13:08:52 +0100 Subject: [PATCH] Allow to define default_result_ttl --- autoworker/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/autoworker/__init__.py b/autoworker/__init__.py index c5c8c2d..4968290 100644 --- a/autoworker/__init__.py +++ b/autoworker/__init__.py @@ -16,7 +16,8 @@ class AutoWorker(object): :param queue: Queue to listen :param max_procs: Number of max_procs to spawn """ - def __init__(self, queue=None, max_procs=None, skip_failed=True): + def __init__(self, queue=None, max_procs=None, skip_failed=True, + default_result_ttl=None): if queue is None: self.queue = 'default' else: @@ -36,6 +37,7 @@ def __init__(self, queue=None, max_procs=None, skip_failed=True): job_class='rq.Job', ) self.skip_failed = skip_failed + self.default_result_ttl = default_result_ttl def worker(self): """Internal target to use in multiprocessing @@ -51,7 +53,8 @@ def worker(self): else: exception_handlers = None worker = worker_class( - q, connection=conn, exception_handlers=exception_handlers + q, connection=conn, exception_handlers=exception_handlers, + default_result_ttl=self.default_result_ttl ) worker._name = '{}-auto'.format(worker.name) worker.work(burst=True)