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
introduce request finalizers into handler chain #9194
Conversation
e0395a2
to
f9451e6
Compare
Changes unknown |
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.
LGTM! This is nice! Lucky for us for now, we didn't run into that kind of issues yet, but it's great to have this. Great catch! Only one small question regarding the boolean finalized
, but otherwise all good!
|
||
self.stopped = False | ||
self.terminated = False | ||
self.finalized = False |
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.
q: when is this set to True
? or how can you set it to True
?
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.
A handler could set it. It's just a way to control things for tests oder other systems that may not want/need familzers
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.
Ah right yes thanks! The Handler
has access to the HandlerChain
. Thanks for answering 😄
Motivation
In the persistence plugin (and perhaps elsewhere), we are using a pattern where we are acquiring locks in request handlers, and freeing them in response handlers, to lock certain things across a request invocation. This can lead to locks never being freed, when handlers (like the CORS enforcer) call
chain.terminate()
, which prevents response handlers from being called.This PR introduces the concept of finalizers into the handler chain, which are always called, even if the chain is terminated. Obviously these should be used sparsely, and only run essential finalization code.
Changes
finalizer: List[Handler]
attribute