{"action":"closed","issue":{"url":"https://api.github.com/repos/gevent/gevent/issues/717","repository_url":"https://api.github.com/repos/gevent/gevent","labels_url":"https://api.github.com/repos/gevent/gevent/issues/717/labels{/name}","comments_url":"https://api.github.com/repos/gevent/gevent/issues/717/comments","events_url":"https://api.github.com/repos/gevent/gevent/issues/717/events","html_url":"https://github.com/gevent/gevent/issues/717","id":124217242,"number":717,"title":"gevent.pywsgi buffers the return value of the application callable","user":{"login":"jamadden","id":1256082,"avatar_url":"https://avatars.githubusercontent.com/u/1256082?v=3","gravatar_id":"","url":"https://api.github.com/users/jamadden","html_url":"https://github.com/jamadden","followers_url":"https://api.github.com/users/jamadden/followers","following_url":"https://api.github.com/users/jamadden/following{/other_user}","gists_url":"https://api.github.com/users/jamadden/gists{/gist_id}","starred_url":"https://api.github.com/users/jamadden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamadden/subscriptions","organizations_url":"https://api.github.com/users/jamadden/orgs","repos_url":"https://api.github.com/users/jamadden/repos","events_url":"https://api.github.com/users/jamadden/events{/privacy}","received_events_url":"https://api.github.com/users/jamadden/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gevent/gevent/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/gevent/gevent/milestones/17","html_url":"https://github.com/gevent/gevent/milestones/1.2","labels_url":"https://api.github.com/repos/gevent/gevent/milestones/17/labels","id":1672945,"number":17,"title":"1.2","description":null,"creator":{"login":"jamadden","id":1256082,"avatar_url":"https://avatars.githubusercontent.com/u/1256082?v=3","gravatar_id":"","url":"https://api.github.com/users/jamadden","html_url":"https://github.com/jamadden","followers_url":"https://api.github.com/users/jamadden/followers","following_url":"https://api.github.com/users/jamadden/following{/other_user}","gists_url":"https://api.github.com/users/jamadden/gists{/gist_id}","starred_url":"https://api.github.com/users/jamadden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamadden/subscriptions","organizations_url":"https://api.github.com/users/jamadden/orgs","repos_url":"https://api.github.com/users/jamadden/repos","events_url":"https://api.github.com/users/jamadden/events{/privacy}","received_events_url":"https://api.github.com/users/jamadden/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":1,"state":"open","created_at":"2016-03-29T22:44:12Z","updated_at":"2016-04-02T21:43:13Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-12-29T14:17:34Z","updated_at":"2016-04-02T21:43:13Z","closed_at":"2016-04-02T21:43:13Z","body":"Before sending any part of the response to the client, `gevent.pywsgi:WSGIHandler` collects all the headers into a `bytearray` known as `towrite`. It then calls `towrite.extend(...)` passing in the results iterable returned by the application callable. Last, it sends everything to the client with a single call to `socket.sendall()`.\r\n\r\nThis has the effect of buffering in memory the entire response produced by the application. This is problematic when the response is large (e.g., a file was returned), or when the application is trying to do Comet-style pushing and returns something like a generator. Furthermore, it [violates the PEP 3333 spec](https://www.python.org/dev/peps/pep-3333/#specification-details)  which states:\r\n\r\n> When called by the server, the application object must return an iterable yielding zero or more bytestrings....The server or gateway **must** transmit the yielded bytestrings to the client in an unbuffered fashion, completing the transmission of each bytestring before requesting another one."}}