Why Python Requests Library Failing To Get Response?
Solution 1:
I believe this is because you are using the Django runserver (correct me if I am wrong) which is not multi-threaded
https://code.djangoproject.com/ticket/3357
So you request to localhost:8000 is queued waiting for the request that made the request to finish! Not ideal.
In production, where you are running your server with a wsgi app (like uwsgi) this would be OK because it is multithreaded.
The reason it works in this test case is because you are making the request from the test thread to the test server that is being run in a different thread.
EDIT #1: A few things to think about
1) Why are your accepting your registration form in a GET request and not a POST request? This is an abuse of the GET verb because you are actually creating something on the server
2) Why are you calling your own API from inside your application and not putting this functionality into a method that can be called from all endpoints that need it?
EDIT #2:
As stated in the comments, the dev server is multithreaded
Post a Comment for "Why Python Requests Library Failing To Get Response?"