Skip to content

Feature: optional pycurl #2269

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

spawn-guy
Copy link
Contributor

@spawn-guy spawn-guy commented Mar 24, 2025

as it was reported urllib3 might be slow(er) than pycurl as an http client. (or even "not working" in 1 unverified report)

this PR brings the curl back. and uses pycurl when available, reverting to urllib3 when not

as the pycurl dependency was removed from being required by sqs extra module
to use pycurl - users need to explicitly add and install pycurl library on their own.

the last required version in pip/requirements.txt format was

pycurl>=7.43.0.5; sys_platform != 'win32' and platform_python_implementation=="CPython"

Copy link

codecov bot commented Mar 24, 2025

Codecov Report

Attention: Patch coverage is 16.00000% with 168 lines in your changes missing coverage. Please review.

Project coverage is 80.20%. Comparing base (f224000) to head (5b40be2).

Files with missing lines Patch % Lines
kombu/asynchronous/http/curl.py 15.73% 162 Missing and 4 partials ⚠️
kombu/asynchronous/http/__init__.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2269      +/-   ##
==========================================
- Coverage   81.55%   80.20%   -1.35%     
==========================================
  Files          77       78       +1     
  Lines        9541     9741     +200     
  Branches     1162     1199      +37     
==========================================
+ Hits         7781     7813      +32     
- Misses       1568     1731     +163     
- Partials      192      197       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Nusnus Nusnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The py-kafka failures are not related

@auvipy
Copy link
Member

auvipy commented Mar 25, 2025

v5.7 or 5.6 for this?

@@ -9,6 +9,10 @@

def Client(hub: Hub | None = None, **kwargs: int) -> BaseClient:
"""Create new HTTP client."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this work as expected? we are not using any try except block here, I'm open to better suggestions as well

Copy link
Contributor Author

@spawn-guy spawn-guy Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've looked at try-catch, but liner was complaining. and.. the .curl code already has this ImportError exception handling. so until the CurlClient is instantiated - there will be no exception. however the CurlClient.Curl will be None.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ima gonna test the code now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code seems to work without pycurl and no thrown Exceptions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@auvipy auvipy modified the milestones: 5.7.0, 5.6.0 Mar 25, 2025
@auvipy
Copy link
Member

auvipy commented Mar 25, 2025

hopefully the kafka builds will pass now

@auvipy
Copy link
Member

auvipy commented Mar 26, 2025

kafka is passing now

@auvipy
Copy link
Member

auvipy commented Mar 27, 2025

for a saner approach, should we just revert it first and then you come with your urllib3 patch again cleanly but keeping pycurl as default one?

@spawn-guy
Copy link
Contributor Author

spawn-guy commented Mar 27, 2025

@auvipy the reverting is not great for me.
i now consider pycurl to be a part of "speedup" extra

but the reported problem is in the existing code from before my changes

@Nusnus
Copy link
Member

Nusnus commented Mar 27, 2025

@spawn-guy

but the reported problem is in the existing code from before my changes

So the slow downs aren't related to the dep changes?
Very interesting

@spawn-guy
Copy link
Contributor Author

@spawn-guy

but the reported problem is in the existing code from before my changes

So the slow downs aren't related to the dep changes?
Very interesting

I can't yet figure out how to install pycurl on awslinux2023 yet (this is why I picked this migration in the first place) to test both speeds.
But I was posting inconsistent speedtest results for some time now

@auvipy
Copy link
Member

auvipy commented Mar 29, 2025

@spawn-guy

but the reported problem is in the existing code from before my changes

So the slow downs aren't related to the dep changes? Very interesting

no they are somewhat related. also we had to use sqs internal / private api which was faster, later we moved to saner public api but with performance regression, then again revert and adding new code. and recently moving to new json protocol properly.

@@ -9,6 +9,10 @@

def Client(hub: Hub | None = None, **kwargs: int) -> BaseClient:
"""Create new HTTP client."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -6,3 +6,4 @@ sphinx2rst>=1.0
bumpversion==0.6.0
pydocstyle==6.3.0
mypy==1.14.1
types-pycurl>=7.43.0.5; sys_platform != 'win32' and platform_python_implementation=="CPython"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is types-pycurl? did the package name changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was suggested by mypy. Otherwise mypy ci was failing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weren't we using only pycurl?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started to get this error only now, and types-pycurl was suggested. The error was related to mypy build (which I am not very familiar with). Then I saw other types-* are already used from the same repo. And then if pycurl is optional then full pycurl dependency is not required and types-pycurl would be sufficient to pass mypy build. I suppose mypy build does typechecking that is why it errored

@spawn-guy
Copy link
Contributor Author

spawn-guy commented Mar 31, 2025

just tested the code. finally solved my pycurl installation automation on amzn2023

so the code in this PR - WORKS! both when pycurl is and is not installed.
the reported str-to-bytes error is also fixed.

however,.. i'll post speed tests soon back in the issue ticket #2258

Copy link
Member

@Nusnus Nusnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to be working finally, thank you so much @spawn-guy 🙏

I'll review it this week

@spawn-guy spawn-guy force-pushed the feature_optinal_pycurl branch from 1e9a732 to 5b40be2 Compare April 7, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants