Skip to content

Commit

Permalink
Merge pull request #9 from gisce/allow_define_default_ttl
Browse files Browse the repository at this point in the history
Allow to define default_result_ttl
  • Loading branch information
ecarreras authored Jan 4, 2018
2 parents 6a330d1 + ea9d7d1 commit 42bb604
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions autoworker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 42bb604

Please sign in to comment.