From 35fb6b0b9ac9ddc1745b6f80d19025e88161fad1 Mon Sep 17 00:00:00 2001 From: Marko Mrdjenovic Date: Sun, 29 Jan 2017 21:53:09 +0100 Subject: [PATCH] move actual execute to a separate method to make it easier to run async jobs --- rq/job.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rq/job.py b/rq/job.py index b820f79..2b34109 100644 --- a/rq/job.py +++ b/rq/job.py @@ -497,11 +497,14 @@ class Job(object): self.ttl = -1 _job_stack.push(self.id) try: - self._result = self.func(*self.args, **self.kwargs) + self._result = self._execute() finally: assert self.id == _job_stack.pop() return self._result + def _execute(self): + return self.func(*self.args, **self.kwargs) + def get_ttl(self, default_ttl=None): """Returns ttl for a job that determines how long a job will be persisted. In the future, this method will also be responsible