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
An attempt at attribute hooks #3
Conversation
I'm thinking that the |
>>> def hook(thimble, attr, val): | ||
... @wraps(val) | ||
... def run_callback_in_reactor_thread_wrapper(*a, **kw): | ||
... callargs = getcallargs(val, *a, **kw) |
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.
This code seems to be quite complicated to be in README. I wonder if you can show a simpler one to easily grasp the idea.
I was initially thinking this feature is not required / complicated but I cannot think of an alternative. |
The only alternative would be like class KazooClientWrapper(object):
def __init__(self, client):
self.client = client
def add_listener(self, listener):
""" Specific impl """
# do stuff
return self.client.add_listener()
def __getattr__(self, name):
return getattr(self.client, name)
txkazooclient = Thimble(reactor, pool, KazooClientWrapper(KazooClient()), ['get']) which I am not sure if is a good idea. |
Nah, I agree, that looks pretty good. I was trying to get a general API out for that, but the thing that came out that covers all the edge cases is just too darn ugly. I'm going to try and do the wrapper thing instead. Thanks @manisht! |
For future communications: my github handle is @manishtomar. Not @manisht :) |
Oops, sorry :( Confused with IRC nick. |
No description provided.