-
Notifications
You must be signed in to change notification settings - Fork 96
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
Fix the 'max_pool_size' parameter passing for Adapters #366
Conversation
In my opinion, further improvement would be nice in the Adapter creation section. The class UDSAdapter(HTTPAdapter):
"""Specialization of requests transport adapter for UNIX domain sockets."""
def __init__(
self,
uds: str,
pool_connections=DEFAULT_POOLSIZE,
pool_maxsize=DEFAULT_POOLSIZE,
max_retries=DEFAULT_RETRIES,
pool_block=DEFAULT_POOLBLOCK,
**kwargs, # <-- It can handle the "unexpected" kwargs
): But the def __init__(
self,
pool_connections=DEFAULT_POOLSIZE,
pool_maxsize=DEFAULT_POOLSIZE,
max_retries=DEFAULT_RETRIES,
pool_block=DEFAULT_POOLBLOCK,
): # There is no "**kwargs", so it can handle only the defined keyword parameters. In the current implementations in the The mainly problematic part. adapter_kwargs = kwargs.copy()
if num_pools is not None:
adapter_kwargs["pool_connections"] = num_pools
if max_pool_size is not None:
adapter_kwargs["pool_maxsize"] = max_pool_size
if timeout is not None:
adapter_kwargs["timeout"] = timeout
if self.base_url.scheme == "http+unix":
self.mount("http://", UDSAdapter(self.base_url.geturl(), **adapter_kwargs))
self.mount("https://", UDSAdapter(self.base_url.geturl(), **adapter_kwargs))
elif self.base_url.scheme == "http+ssh":
self.mount("http://", SSHAdapter(self.base_url.geturl(), **adapter_kwargs))
self.mount("https://", SSHAdapter(self.base_url.geturl(), **adapter_kwargs))
elif self.base_url.scheme == "http":
self.mount("http://", HTTPAdapter(**adapter_kwargs))
self.mount("https://", HTTPAdapter(**adapter_kwargs))
else:
assert False, "APIClient.supported_schemes changed without adding a branch here." I can implement it in another PR (Or extending this one), if you want. |
@milanbalazs |
Thanks for the PR @milanbalazs! Can you please make this backward compatible so we don't break any users. |
Signed-off-by: Milan Balazs <[email protected]>
I have just added a new commit which contains the backward compatible solution (And providing My minimal test about the parameter usage:
|
Thank you! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: milanbalazs, umohnani8 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@milanbalazs I think validate is failing because the subject of the commit message is too long, it should be less than 72 characters. Can you please fix that and push. |
Fix the parameter passing for HttpAdapter Signed-off-by: Milan Balazs <[email protected]>
Signed-off-by: Milan Balazs <[email protected]>
With this custom warning class only the specific warning will be shown to user (warnings.simplefilter). It doesn't affect to other Warings in other modules. Signed-off-by: Milan Balazs <[email protected]>
Thanks! I have just made shorter the problematic commit massage. |
/lgtm |
Thanks to merge my PR! When do you plan to create a new release which contains my fix (PyPi package)? |
@milanbalazs I created a new 4.9 release with your changes included in it. |
The
max_pool_size
was typedmax_pools_size
in theAPIClient
class and it caused issue.Test code:
Output:
If I set the
max_pool_size
parameter in thefrom_env
method (client = podman.from_env(max_pool_size=requests.adapters.DEFAULT_POOLSIZE)
), the output is (the same):If I use
max_pools_size
instead ofmax_pool_size
, the output is:Based on the above analysis, it's clearly visible the parameter passing is not correct...
Furthermore the implementation and the docstring are not matched (pool -> pools):
I have check the complete source code and I haven't found reference for
max_pools_size
parameter so I think my change is compatible with the source code.Note:
APIClient
directly and themax_pools_size
parameter is passed, then that implementation won't be working after my change because the parameter is renamed. But it can be made for backward compatible is it's preferred.The tested system: