1# -*- coding: utf-8 -
2#
3# This file is part of gunicorn released under the MIT license.
4# See the NOTICE for more information.
5
6
7import sys
8import time
9
10class TestIter(object):
11
12    def __iter__(self):
13        lines = ['line 1\n', 'line 2\n']
14        for line in lines:
15            yield line
16            time.sleep(20)
17
18def app(environ, start_response):
19    """Application which cooperatively pauses 20 seconds (needed to surpass normal timeouts) before responding"""
20    status = '200 OK'
21    response_headers = [
22        ('Content-type', 'text/plain'),
23        ('Transfer-Encoding', "chunked"),
24    ]
25    sys.stdout.write('request received')
26    sys.stdout.flush()
27    start_response(status, response_headers)
28    return TestIter()
29