-
-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raise ResultNotFound when Job.result() finds no job and no result #364
Conversation
Job.result() assumed that a result will eventually show up in Redis. This assumption does not hold for jobs which are not in the queue and jobs which do not keep result. In such cases Job.result() would hang forever (or until the optional timeout is reached). This PR changes Job.result() so that it raises a new exception ResultNotFound, rather than waiting forever, if result is not found and the job is not in the queue.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #364 +/- ##
==========================================
+ Coverage 98.80% 98.81% +0.01%
==========================================
Files 11 9 -2
Lines 1007 932 -75
Branches 185 172 -13
==========================================
- Hits 995 921 -74
Misses 6 6
+ Partials 6 5 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good idea to me, just a few things to change to change.
Also can you add some info about this to result
docstring.
I'll try to make a new release tomorrow, would be great if we could include this. |
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
I updated docstring and error message. If you want to change wording feel free to push directly to this branch. |
The new
The first two options seem most sensible to me and I chose to catch and return |
Great, thanks so much.
Agreed, I think returning |
Hi @iamlikeme! Quick question about this PR, I noticed this part in async with self._redis.pipeline(transaction=True):
v = await self._redis.get(result_key_prefix + self.job_id)
s = await self._redis.zscore(self._queue_name, self.job_id) A transaction is created but not used for the two queries; is that on purpose? Couldn't it create a possible false ResultNotFound if the job is done and removed from the queue after the first line but before the second? |
@iamlikeme Thank you for your contributions! |
Job.result() assumed that a result will eventually show up in Redis. This assumption does not hold for jobs which are not in the queue and jobs which do not keep result. In such cases Job.result() would hang forever (or until the optional timeout is reached).
This PR changes Job.result() so that it raises a new exception ResultNotFound, rather than waiting forever, if result is not found and the job is not in the queue.