Closed cjwatson closed 4 years ago
Interesting, I'm surprised this issue hasn't shown up before. Was there a particular context in which it showed up for you?
In any case, seems like a good fix. I'll give it some real attention tomorrow.
Yes, it showed up in our test suite when I tried to upgrade Launchpad from wsgi-intercept 0.5.1 to 1.9.1 (we were stuck on an old version until recently, because until I did some major refactoring work we were relying on wsgi-intercept to intercept zope.testbrowser calls). The topmost item in our test middleware stack happens to be an access logger, which was most easily written as a generator.
I'll have a release of this in a few minutes.
If the WSGI app is a generator function (using "yield"), then it won't do anything at all until its first iteration, including setting headers or calling start_response to write the status line of the response. Turn the handle once to make sure that the app has started before writing headers.