-
-
Notifications
You must be signed in to change notification settings - Fork 286
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
Each queue should be able to have its custom_exception or None. #215
base: master
Are you sure you want to change the base?
Conversation
How can i run tests in my machine? |
… of a test. I cannot send a failed job to failed
I agree that this is a good idea. However, I'd like to keep it backwards compatible if we can. Could you please change your PR to make |
Will do ;) |
i'm sorry, i was really busy those days ;) Take a look and see if it fits ^^ |
django_rq/workers.py
Outdated
} | ||
""" | ||
return [import_attribute(path) for path in EXCEPTION_HANDLERS] | ||
try: | ||
from django.settings import RQ_EXCEPTION_HANDLERS |
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.
RQ_EXCEPTION_HANDLERS
should only be a fallback. So we only try to import it if exception_handlers
is None
.
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.
Ok, i will rewrite asap ;)
Done, could you take a look if it's ok? Cheers! |
django_rq/workers.py
Outdated
Custom exception handlers could be defined in settings.py: | ||
RQ = { | ||
'EXCEPTION_HANDLERS': ['path.to.handler'], | ||
def get_exception_handlers(exception_handlers): |
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.
I think it's better to change the function signature to get_exception_handlers(queue_name)
@@ -49,6 +49,7 @@ class DjangoRQ(Queue): | |||
def __init__(self, *args, **kwargs): | |||
autocommit = kwargs.pop('autocommit', None) | |||
self._autocommit = get_commit_mode() if autocommit is None else autocommit | |||
self.exception_handlers = kwargs.pop('exception_handlers', None) |
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.
There's no need to store exception_handlers
as property in DjangoRQ
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.
Ok. About the failing tests, idk how to fix it because, once the exception handler comes in, i couldn't find how to put them in failed again if they fail.
That's the problem with the test. The failed job never go to failed after a exception_handlers takes in. :(
I would like some help about it , if possible.
Thanks! ^^
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.
You can simply write a test for get_queue('default')
and ensure that queue.exception_handlers
contains the exception handler you specified in settings.
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.
Sorry, the test should be for get_worker()
because only workers have exception_handlers
. Queue
objects have no exception_handlers
in RQ.
@fchevitarese could you also fix the failing tests? |
…s by checking if have a custom exception, otherwise, it start a Worker without the parameter.
@selwin , the only way i found to fix the testing was to check if exception_handler exists, and if not, start a Worker without the parameter. I'm not sure why, and i couldn't find a way to fix this problem in other way. About the property "self.exception_handlers = kwargs.pop('exception_handlers', None)" i removed, but started to face a lot of errors, so i put it back. Hope it's all good! |
@@ -77,7 +77,8 @@ def handle(self, *args, **options): | |||
queues, | |||
connection=queues[0].connection, | |||
name=options['name'], | |||
exception_handlers=get_exception_handlers() or None, | |||
exception_handlers=get_exception_handlers( |
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.
I don't think this is right. The function is defined as get_exception_handlers(queue_name)
but you're passing in queue.exception_handlers
here.
return queue_class(name, default_timeout=default_timeout, | ||
connection=get_connection(name), async=async, | ||
autocommit=autocommit) | ||
autocommit=autocommit, | ||
exception_handlers=exception_handlers) |
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.
You should also import exception_handlers
before passing it into __init__
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.
@fchevitarese reminder to update this PR when you're free :)
Hi! I'm sorry I've been very busy. Will do when I can
Em 22/07/2017 21:54, "Selwin Ong" <[email protected]> escreveu:
… ***@***.**** commented on this pull request.
------------------------------
In django_rq/queues.py
<#215 (comment)>:
> return queue_class(name, default_timeout=default_timeout,
connection=get_connection(name), async=async,
- autocommit=autocommit)
+ autocommit=autocommit,
+ exception_handlers=exception_handlers)
@fchevitarese <https://github.com/fchevitarese> reminder to update this
PR when you're free :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#215 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AACAx9KbgEC1fsa7LejrT_heZOToLfa0ks5sQpmogaJpZM4LxhAD>
.
|
Each queue should be able to have its custom_exception or None.
Make a global custom_exception may lead us to a non desired behavior on other queues.