I run django with uwsgi server. My code contains many api calls with urllib2 like this:
with closing(urllib2.urlopen(request, timeout=1)) as f:
content = f.read()
Even when I set socket timeout I see request takes more seconds that I'd like. I guess it happens because timeout limits socket connection but not data reading.
And I want to limit this code block. Tried to achieve it with signal.SIGALRM
but it doesn't work with uwsgi (I run without enable-threads
). But it works with Apache+mod_wsgi. Thread timeout looks unreliable.
No errors, SIGALRM is just ignored either harakiri mode or not. I'm not good in reading C source code but the reason of such behavior here.