-
Notifications
You must be signed in to change notification settings - Fork 610
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
Add support for functools.partial in ExternalSource. #3143
Conversation
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
!build |
CI MESSAGE: [2563586]: BUILD STARTED |
CI MESSAGE: [2563586]: BUILD PASSED |
if call == x: | ||
return 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.
Without the lines 225-227 we got here. Then the functools.partial wrapper ended up having __call__
point to the itself which triggered infinite recursion. This condition prevents this from happening for in other cases. Note that the worst thing that can happen here is that we miss a generator function - much less problematic than crashing on an otherwise good callback.
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.
What happens if we miss generator function here?
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.
Are there any other cases where call==x?
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.
What happens if we miss generator function here?
It won't work as a generator function - so the particular use case is not handled
Are there any other cases where call==x?
None so far, but I'd venture a guess that there might be something implemented in a similar way that functools.partial
was.
@@ -222,9 +222,14 @@ def _is_generator_function(x): | |||
where __call__ is a generator function""" | |||
if inspect.isgeneratorfunction(x): | |||
return True | |||
if isinstance(x, functools.partial): | |||
return _is_generator_function(x.func) |
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.
The field/property func
comes from:
https://docs.python.org/3/library/functools.html#functools.partial
Signed-off-by: Michał Zientkiewicz mzient@gmail.com
Why we need this PR?
Pick one, remove the rest
functools.partial
is passed to ExternalSourceWhat happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
functools.partial
and if so, use itsfunc
field instead to check if it's a generator function__call__
field points to selfJIRA TASK: N/A