def __call__(self, request):
        parts = []
        parts_append = parts.append

        base_header = strftime('\r\nDate: %a, %d %b %Y %H:%M:%S GMT', gmtime()) + '\r\nServer: tornado\r\n'
        if not request.supports_http_1_1():
            if request.headers.get('Connection', '').lower() == 'keep-alive':
                base_header += 'Connection: Keep-Alive\r\n'

        def start_response(status, response_headers, exc_info=None):
            parts_append(utf8('HTTP/1.1 ' + status + base_header))
            for key, value in response_headers:
                parts_append(utf8(key + ': ' + value + '\r\n'))
            parts_append(self.new_line)
            return None

        environ = WSGIContainer.environ(request)
        environ['wsgi.multiprocess'] = False # Some EvalException middleware fails if set to True

        app_response = self.wsgi_application(environ, start_response)
        if not parts:
            raise Exception('WSGI app did not call start_response')

        if request.method != 'HEAD':
            parts.extend(app_response)

        if hasattr(app_response, 'close'):
            app_response.close()
        app_response = None

        if hasattr(request, "connection"):
            # Now that the request is finished, clear the callback we
            # set on the IOStream (which would otherwise prevent the
            # garbage collection of the RequestHandler when there
            # are keepalive connections)
            request.connection.stream.set_close_callback(None)

        request.write(self.empty_string.join(parts))
        try:
            request.finish()
        except __HOLE__ as e:
            self.logger.error('Exception when writing response: %s', str(e))
dataset/ETHPy150Open turbulenz/turbulenz_local/turbulenz_local/paste_factory.py/DevserverWSGIContainer.__call__