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
[FEATURE] Use httpx
for the transport layer
#1968
Comments
and there seems to be a transition to httpx so your code would be more interoperable |
everyone has his own library preferences ;). It is just my recommendation. |
There is a long-running plan to switch to httpx (specifically in #1718 and previously discussed in some more issues) for multiple reasons, the main one for me is the cancellation in CLI. While I agree with the reasoning you provided, I feel that this is more like a duplicate of #1718 that suggests providing multiple transports instead of a complete switch (it also will unblock alternative transports that could be something useful for future gRPC support). A complete switch would be backward-incompatible for many users who would be forced to switch to using httpx in their tests and with pluggable transports such a transition would be smoothened. It is completely fine to switch rapidly for apps, but for a library on which many users rely on, I'd prefer to take a more flexible way. As a side note, what kind of boilerplate did you mention? I am genuinely interested in reducing the amount of boilerplate, but I'd like to have some actionable inputs and clearly see how httpx will help to avoid it - it will also help me to provide a better API from the Schemathesis side for all users. |
Now, I also see that #1718 lacks certain implementation details about the transport layer. I'm going to update it soon |
thanks! And sorry for the duplicate Found another frustrating bug: requests.Session is incompatible with asgi/wsgi |
an idea: you have the method get_requests_kwargs. Check if the class is requests.Session or httpx.Session and transform the arguments accordingly or remove if not supported. This way httpx Session can be used by default (and the boilerplate code removed) and requests.Session only if explicitly specified (it doesn't supports wsgi/asgi calls anyway as far as I know) |
httpx
for the transport layer
Is your feature request related to a problem? Please describe
Currently schemathesis uses requests. This has following drawbacks:
I would recommend to migrate away from requests and can recommend httpx as alternative.
There are maybe some other nice libraries out there but httpx has two killer features:
@Stranger6667:
Moving all the current transports to
httpx
will have the extra benefit of droppingstarlette_test_client
,werkzeug
&requests
. I hope all of them can be dropped and we can use just differenthttpx
transports.Also, the Schemathesis test runner will benefit from async execution of requests which will be simpler to implement as it will help with cancellation (i.e. httpbin's
drip
endpoint can hang schemathesis)On the implementation side of things, the ASGI transport is async, but the main flow is sync, so we need an adapter to run those requests synchronously.
Such a change will likely happen with the
4.0
release.The text was updated successfully, but these errors were encountered: