WSGIRequest._stream.read() blocking

220 views
Skip to first unread message

Jonathan Slenders

unread,
Jun 14, 2011, 8:54:10 AM6/14/11
to Django developers
Hi all,


Using WSGI on production environment:

In django.core.handlers.wsgi.py is a clear notice that wsgi.input,
which can be an instance of socket._fileobject will hang when reading
past the available count.

In my case, wsgi.input appears to be of the type 'file', so the
following test fails, and the input is not wrapped in a LimitedStream.

-----------------------
wsgi.input.__class__
<type 'file'>

wsgi.input.__class__.__name__
file

wsgi.input
<open file 'wsgi_input', mode 'r' at 0x9816650>

socket._fileobject
<class 'socket._fileobject'>

type(socket._fileobject)
<type 'type'>

isinstance(self.environ['wsgi.input'], socket._fileobject)
False

-----------------------

When I want to read request.raw_post_data, everything hangs.

It may be worth noting that the CONTENT_LENGTH was zero. (It is sentry
in my case who wants to log another error, tries to access
raw_post_data, and blocks instead of returning a proper 500 error
page.)
This is probably a bug in Django, but I'm not sure where exactly.

By the way, it would also be great if anybody knows how to use pdb
statements, while running uwsgi on the console.

Thanks!
Jonathan

Jonathan Slenders

unread,
Jun 14, 2011, 8:57:06 AM6/14/11
to Django developers
if I replace:

> if type(socket._fileobject) is type and isinstance(self.environ['wsgi.input'], socket._fileobject):

by:

> if True

in django.core.handlers.wsgi.py
Then, everything works perfect, so it has to be in this check.

Roberto De Ioris

unread,
Jun 14, 2011, 9:00:31 AM6/14/11
to django-d...@googlegroups.com

Even if the read() and read(-1) are controversial, the popular consensus is on having the WSGI server to
gracefully manages it.

uWSGI 0.9.8 uses the same approach of mod_wsgi (it creates a custom object for wsgi.input), so you are using a old uWSGI version
or i did not understand your question :)

>
> By the way, it would also be great if anybody knows how to use pdb
> statements, while running uwsgi on the console.


Look here,
http://lists.unbit.it/pipermail/uwsgi/2011-April/001769.html

the same is valid for pratically all of the other WSGI daemons out there.

--
Roberto De Ioris
http://unbit.it

Aymeric Augustin

unread,
Jun 14, 2011, 9:02:37 AM6/14/11
to django-d...@googlegroups.com
Hi Jonathan,


Best regards,

-- 
Aymeric Augustin.

2011/6/14 Jonathan Slenders <jonathan...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.




--
Aymeric.

Jonathan Slenders

unread,
Jun 14, 2011, 9:17:40 AM6/14/11
to Django developers
Thanks Roberto,

We had UWSGI 0.9.6.8 installed first. Now I did an upgrade to 0.9.8
and now everything works perfect.

Thanks a lot for the quick response.
> Look here,http://lists.unbit.it/pipermail/uwsgi/2011-April/001769.html

Tom Christie

unread,
Jun 14, 2011, 11:34:24 AM6/14/11
to django-d...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages