kevinsl / wsgi-intercept

Automatically exported from code.google.com/p/wsgi-intercept
Other
0 stars 0 forks source link

WSGI PEP is violated - iterators' close() method isn't called #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Apply wsgi_compliance_test.diff.  It adds a test that's just a copy of
the httplib2 test with paste.lint added.
2. Do "nosetests test.test_wsgi_compliance"

What is the expected output? What do you see instead?

The test passes from nose's perspective, but emits the following on stderr:

Iterator garbage collected without being closedException
exceptions.AssertionError: AssertionError('Iterator garbage collected
without being closed',) in <bound method IteratorWrapper.__del__ of
<paste.lint.IteratorWrapper object at 0x1342110>> ignored

The test doesn't actually fail because lint detects the error too late - it
only knows something's gone wrong when __del__ is called.

What version of the product are you using? On what operating system?

svn rev 34

Please provide any additional information below.

In the "Specification Details" section, the WSGI PEP says:

"""
If the iterable returned by the application has a close() method, the
server or gateway must call that method upon completion of the current
request, whether the request was completed normally, or terminated early
due to an error.
"""

The attached wsgi_iterator_compliance_fix.diff modifies
wsgi_fake_socket.makefile to do as the spec asks, and lint stops
complaining.  It does still emit a warning about QUERY_STRING being absent,
though.

Original issue reported on code.google.com by gary.ber...@gmail.com on 6 Jan 2008 at 7:34

Attachments:

GoogleCodeExporter commented 8 years ago
Good catch, fixed in rev 36 of rel_0_3 branch.  I also fixed the QUERY_STRING 
while
in there but I too couldn't think of a way to make a failing test for the close
problem.  Got rid of the warning anyway.  I rolled this up with issue7 and 
pushed out
a 0.3.2 release.

easy_install -U wsgi_intercept should pull them in.

thanks again!

Original comment by kumar.mcmillan on 6 Jan 2008 at 9:19