Exemplo n.º 1
0
def make_server(app, host=None, port=None, backend='wsgiref', backlog=2048,
                spawn=None, logger=None, address_family=socket.AF_INET,
                socket_type=socket.SOCK_STREAM, graceful_timeout=None):

    logger = logger or chaussette_logger
    logger.info('Application is %r' % app)
    if host.startswith('fd://') or host.startswith('unix:'):
        logger.info('Serving on %s' % host)
    else:
        logger.info('Serving on %s:%s' % (host, port))

    server_class = get(backend)
    logger.info('Using %r as a backend' % server_class)
    if spawn:
        logger.info('Spawning method: %r' % spawn)
    server_class_kwargs = {
        'backlog': backlog,
        'address_family': address_family,
        'socket_type': socket_type,
    }
    if spawn is not None:
        server_class_kwargs['spawn'] = spawn
    if graceful_timeout is not None:
        server_class_kwargs['graceful_timeout'] = graceful_timeout

    try:
        server = server_class((host, port), app, **server_class_kwargs)
    except TypeError:
        logger.exception("Failed to create backend %s, you might be trying "
                         "to use --spawn on a backend that does "
                         "not support it" % backend)
        raise
    return server
Exemplo n.º 2
0
def make_server(app, host=None, port=None, backend='wsgiref', backlog=2048):
    print('Application is %r' % app)
    if host.startswith('fd://'):
        print('Serving on %s' % host)
    else:
        print('Serving on %s:%s' % (host, port))

    server_class = get(backend)
    print('Using %r as a backend' % server_class)
    server = server_class((host, port), app, backlog=backlog)
    return server
Exemplo n.º 3
0
def make_server(app, host=None, port=None, backend='wsgiref', backlog=2048):
    print('Application is %r' % app)
    if host.startswith('fd://'):
        print('Serving on %s' % host)
    else:
        print('Serving on %s:%s' % (host, port))

    server_class = get(backend)
    print('Using %r as a backend' % server_class)
    server = server_class((host, port), app, backlog=backlog)
    return server
Exemplo n.º 4
0
def make_server(app, host=None, port=None, backend='wsgiref', backlog=2048,
                logger=None):
    logger = logger or chaussette_logger
    logger.info('Application is %r' % app)
    if host.startswith('fd://'):
        logger.info('Serving on %s' % host)
    else:
        logger.info('Serving on %s:%s' % (host, port))

    server_class = get(backend)
    logger.info('Using %r as a backend' % server_class)
    server = server_class((host, port), app, backlog=backlog)
    return server
Exemplo n.º 5
0
def make_server(app, host=None, port=None, backend='wsgiref', backlog=2048,
                logger=None, address_family=socket.AF_INET,
                socket_type=socket.SOCK_STREAM):
    logger = logger or chaussette_logger
    logger.info('Application is %r' % app)
    if host.startswith('fd://') or host.startswith('unix:'):
        logger.info('Serving on %s' % host)
    else:
        logger.info('Serving on %s:%s' % (host, port))

    server_class = get(backend)
    logger.info('Using %r as a backend' % server_class)
    server = server_class((host, port), app, backlog=backlog,
                          address_family=address_family,
                          socket_type=socket_type)
    return server
Exemplo n.º 6
0
def make_server(app,
                host=None,
                port=None,
                backend='wsgiref',
                backlog=2048,
                spawn=None,
                logger=None,
                address_family=socket.AF_INET,
                socket_type=socket.SOCK_STREAM,
                graceful_timeout=None,
                disable_monkeypatch=False):

    logger = logger or chaussette_logger
    logger.info('Application is %r' % app)
    if host.startswith('fd://') or host.startswith('unix:'):
        logger.info('Serving on %s' % host)
    else:
        logger.info('Serving on %s:%s' % (host, port))

    server_class = get(backend)
    logger.info('Using %r as a backend' % server_class)
    if spawn:
        logger.info('Spawning method: %r' % spawn)
    server_class_kwargs = {
        'backlog': backlog,
        'address_family': address_family,
        'socket_type': socket_type,
        'disable_monkeypatch': disable_monkeypatch
    }

    if spawn is not None:
        server_class_kwargs['spawn'] = spawn
    if graceful_timeout is not None:
        server_class_kwargs['graceful_timeout'] = graceful_timeout

    try:
        server = server_class((host, port), app, **server_class_kwargs)
    except TypeError:
        logger.exception("Failed to create backend %s, you might be trying "
                         "to use --spawn on a backend that does "
                         "not support it" % backend)
        raise
    return server
Exemplo n.º 7
0
def make_server(
    app,
    host=None,
    port=None,
    backend="wsgiref",
    backlog=2048,
    logger=None,
    address_family=socket.AF_INET,
    socket_type=socket.SOCK_STREAM,
):
    logger = logger or chaussette_logger
    logger.info("Application is %r" % app)
    if host.startswith("fd://") or host.startswith("unix:"):
        logger.info("Serving on %s" % host)
    else:
        logger.info("Serving on %s:%s" % (host, port))

    server_class = get(backend)
    logger.info("Using %r as a backend" % server_class)
    server = server_class((host, port), app, backlog=backlog, address_family=address_family, socket_type=socket_type)
    return server