I am probably being a fool here, it's 0035 local time and my brain isn't exactly running at maximum throughput, but I thought it best to ask just in case.
In the initial build of my web app, I encountered a situation where I needed to retrieve data from an external service which in turn needed to retrieve a file from my app (file served via the standard static handling process).
Yes, I know it's strange, but it's a stand-in allowing me to move forward with other things and then drop in a proper implementation when it's ready.
So, we have something like this:
def weird_view(request):
result = urllib2.urlopen("https://some.webservice.com/?url=http://mywebapp.pythonanywhere.com/path/to/file.ext")
...
return HttpResponse(something)
When this view is called via uWSGI, the server process hangs until the external service times out and aborts the request. If I change the first line to:
result = urllib2.urlopen("http://mywebapp.pythonanywhere.com/url/goes/here")
The server process hangs completely, requiring a reload of the app to come back! In either case, if I call the view from a Python console it doesn't hang and I get my HttpResponse object like I should.
I then pointed a domain at my app using the standard instructions, which allowed everything to work fine. One request (the initial to the Django view) goes to the domain, and the secondary urlopen request goes to the PythonAnywhere subdomain.
While performing HTTP requests to your own site from within a view is icky and deserving of a DailyWTF post, uWSGI should be able to handle cases like this - it can handle concurrent requests, can't it?