Exemplo n.º 1
0
import guv
guv.monkey_patch()

import guv.wsgi
import logger

logger.configure()


def app(environ, start_response):
    """
    This is very basic WSGI app useful for testing the performance of guv and guv.wsgi without
    the overhead of a framework such as Flask. However, it can just as easily be any other WSGI app
    callable object, such as a Flask or Bottle app.
    """
    status = '200 OK'
    output = [b'Hello World!']
    content_length = str(len(b''.join(output)))

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', content_length)]

    start_response(status, response_headers)

    return output


if __name__ == '__main__':
    server_sock = guv.listen(('0.0.0.0', 8001))
    guv.wsgi.serve(server_sock, app)
Exemplo n.º 2
0
used to serve valid HTTP (as far as ``wrk`` is concerned) to benchmark concurrency and requests/sec.

Three basic client handlers are provided:

- :func:`handle_http_10` acts as an HTTP 1.0 server which sends a static message and closes the
  connection (HTTP header ``Connection: close``, which is default for HTTP 1.0).
- :func:`handle_http_11` acts as an HTTP 1.1 server which sends a static message, but keeps the
  connection alive (HTTP header ``Connection: keep-alive``, which is default for HTTP 1.1).
- :func:`handle_http` is a slightly more complex client handler which actually reads the client's
  request and decides to either close or keep-alive the connection based on the HTTP version and
  what the client wants. If the connection is to be kept alive, this handler cooperatively yields
  control to other greenlets after every request, which significantly improves request/response
  latency (as reported by wrk).
"""
import guv
guv.monkey_patch()

import guv.server
import guv.hubs
import guv.greenio
from guv import gyield
from guv.support import PYPY

import logging

import logger

logger.configure()
log = logging.getLogger()

if PYPY:
Exemplo n.º 3
0
 def patch(self):
     guv.monkey_patch(os=False)
     patch_sendfile()