<s> from __future__ import absolute_import <EOL> from functools import wraps <EOL> import gevent . monkey <EOL> from paste . deploy . converters import asbool <EOL> from . . server import FastCGIServer <EOL> def server_params ( app , conf , host = '<STR_LIT:127.0.0.1>' , port = <NUM_LIT> , socket = None , <EOL> ** kwargs ) : <EOL> address = ( host , int ( port ) ) if socket is None else socket <EOL> for name in kwargs . keys ( ) : <EOL> if name in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) : <EOL> kwargs [ name ] = int ( kwargs [ name ] ) <EOL> elif name . startswith ( '<STR_LIT>' ) and asbool ( kwargs . pop ( name ) ) : <EOL> name = name [ <NUM_LIT> : ] <EOL> if name in gevent . monkey . __all__ : <EOL> getattr ( gevent . monkey , name ) ( ) <EOL> return ( app , address ) , kwargs <EOL> @ wraps ( server_params ) <EOL> def fastcgi_server_runner ( * args , ** kwargs ) : <EOL> ( handler , address ) , kwargs = server_params ( * args , ** kwargs ) <EOL> FastCGIServer ( address , handler , ** kwargs ) . serve_forever ( ) <EOL> @ wraps ( server_params ) <EOL> def wsgiref_server_runner ( * args , ** kwargs ) : <EOL> from . . wsgi import WSGIRefRequestHandler <EOL> ( app , address ) , kwargs = server_params ( * args , ** kwargs ) <EOL> handler = WSGIRefRequestHandler ( app ) <EOL> FastCGIServer ( address , handler , ** kwargs ) . serve_forever ( ) <EOL> @ wraps ( server_params ) <EOL> def wsgi_server_runner ( * args , ** kwargs ) : <EOL> from . . wsgi import WSGIRequestHandler <EOL> ( app , address ) , kwargs = server_params ( * args , ** kwargs ) <EOL> handler = WSGIRequestHandler ( app ) <EOL> FastCGIServer ( address , handler , ** kwargs ) . serve_forever ( ) </s>
