当前位置: 首页>>代码示例>>Python>>正文


Python server.listen函数代码示例

本文整理汇总了Python中meinheld.server.listen函数的典型用法代码示例。如果您正苦于以下问题:Python listen函数的具体用法?Python listen怎么用?Python listen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了listen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(
        self, listener, application=None, backlog=2048, socket_type=socket.SOCK_STREAM, address_family=socket.AF_INET
    ):
        self.address_family = address_family
        self.socket_type = socket_type
        from meinheld import patch

        patch.patch_all()
        server.set_backlog(backlog)
        host, port = listener
        if host.startswith("fd://"):
            fd = int(host.split("://")[1])
            server.set_listen_socket(fd)
        else:
            if self.address_family == socket.AF_UNIX:
                filename = listener[0][len("unix:") :]

                try:
                    os.remove(filename)
                except OSError:
                    pass
                server.listen(filename)
            else:
                server.listen(listener)

        self.application = application
开发者ID:acdha,项目名称:chaussette,代码行数:26,代码来源:_meinheld.py

示例2: run

 def run(self, port, hostname, **kwargs):
     from meinheld import server, patch
     patch.patch_all()
     print(" - Running Hosting Server using Meinheld")
     print(" - http://%s:%s/" % (hostname, port))
     server.listen((hostname, port))
     server.run(self.app)
开发者ID:stone5495,项目名称:flask-boilerplate-utils,代码行数:7,代码来源:commands.py

示例3: run

    def run(self, handler): # pragma: no cover
        import tornado.wsgi, tornado.httpserver, tornado.ioloop

        container = tornado.wsgi.WSGIContainer(handler)
        server = tornado.httpserver.HTTPServer(container)
        server.listen(port=self.port)
        tornado.ioloop.IOLoop.instance().start()
开发者ID:4Christopher,项目名称:pyload,代码行数:7,代码来源:servers.py

示例4: main

def main():
    opts, args = getopt.parse_args()

    if opts.debug:
        application.debug = True

    print "Server listen: http://%s:%s/" % (opts.address, opts.port)
    server.listen((opts.address, opts.port))
    server.run(application)
开发者ID:hagihala,项目名称:gily,代码行数:9,代码来源:server.py

示例5: test_getsockopt

def test_getsockopt():
    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        tr = s.getsockopt(msocket.IPPROTO_TCP, msocket.TCP_NODELAY)
        assert(tr > 0)
        server.shutdown()

    server.listen(("0.0.0.0", 8000))
    server.spawn(_test)
    server.run(App())
开发者ID:apackeer,项目名称:meinheld,代码行数:10,代码来源:test_socket.py

示例6: test_fileno

def test_fileno():

    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        assert(s.fileno() > 2)
        server.shutdown()

    server.listen(("0.0.0.0", 8000))
    server.spawn(_test)
    server.run(App())
开发者ID:apackeer,项目名称:meinheld,代码行数:10,代码来源:test_socket.py

示例7: test_detach

def test_detach():

    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        s.detach()
        server.shutdown()

    server.listen(("0.0.0.0", 8000))
    server.spawn(_test)
    server.run(App())
开发者ID:apackeer,项目名称:meinheld,代码行数:10,代码来源:test_socket.py

示例8: test_sock

def test_sock():

    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        assert(type(s) == msocket.socket)
        server.shutdown()

    server.listen(("0.0.0.0", 8000))
    server.spawn(_test)
    server.run(App())
开发者ID:apackeer,项目名称:meinheld,代码行数:10,代码来源:test_socket.py

示例9: test_connect_ex

def test_connect_ex():

    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        s.connect_ex(("localhost", 8000))
        server.shutdown()

    server.listen(("0.0.0.0", 8000))
    server.spawn(_test)
    server.run(App())
开发者ID:apackeer,项目名称:meinheld,代码行数:10,代码来源:test_socket.py

示例10: test_connect_fail

def test_connect_fail():

    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        with raises(msocket.gaierror):
            s.connect(("google.comaaa", 80))
        server.shutdown()

    server.listen(("0.0.0.0", 8000))
    server.spawn(_test)
    server.run(App())
开发者ID:apackeer,项目名称:meinheld,代码行数:11,代码来源:test_socket.py

示例11: meinheld_server_runner

def meinheld_server_runner(wsgi_app, global_config, **settings):
    from meinheld import server, middleware
    host = settings.get('host', '0.0.0.0')
    port = int(settings.get('port', 8080))

    server.listen((host, port))
    server.set_access_logger(None)
    server.set_error_logger(None)

    print('Starting HTTP server on http://%s:%s' % (host, port))
    server.run(middleware.WebSocketMiddleware(wsgi_app))
开发者ID:sokky,项目名称:wsocket,代码行数:11,代码来源:__init__.py

示例12: test_sendto

def test_sendto():
    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        s.connect(("localhost", 8000))
        s.sendto(b"GET / HTTP/1.0\r\n\r\n", (b'localhost',8000))
        assert(len(s.recv(1024)) == 135)
        server.shutdown()

    server.listen(("0.0.0.0", 8000))
    server.spawn(_test)
    server.run(App())
开发者ID:apackeer,项目名称:meinheld,代码行数:11,代码来源:test_socket.py

示例13: test_timeout

def test_timeout():
    def _test():
        val = 5
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        s.settimeout(val)
        assert(val == s.gettimeout())
        server.shutdown()

    server.listen(("0.0.0.0", 8000))
    server.spawn(_test)
    server.run(App())
开发者ID:apackeer,项目名称:meinheld,代码行数:11,代码来源:test_socket.py

示例14: __init__

    def __init__(self, listener, application=None, backlog=2048):
        from meinheld import patch
        patch.patch_all()
        server.set_backlog(backlog)
        host, port = listener
        if host.startswith('fd://'):
            fd = int(host.split('://')[1])
            server.set_listen_socket(fd)
        else:
            server.listen(listener)

        self.application = application
开发者ID:KristianOellegaard,项目名称:chaussette,代码行数:12,代码来源:_meinheld.py

示例15: test_makefile

def test_makefile():
    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        s.connect(("localhost", 8000))
        f = s.makefile()
        assert(f)

        server.shutdown()

    server.listen(("0.0.0.0", 8000))
    server.spawn(_test)
    server.run(App())
开发者ID:apackeer,项目名称:meinheld,代码行数:12,代码来源:test_socket.py


注:本文中的meinheld.server.listen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。