• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python server.listen函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: start

def start(name):
    print "started server at "+str(host)+":"+str(port)
    if name =="meinheld":
        from meinheld import server
        server.set_access_logger(None)
        server.set_error_logger(None)
        server.listen((host, port))
        server.run(app)
    elif name =="gevent":
        #from gevent import wsgi 
        #wsgi.WSGIServer((host, port), application=app.application, log=None).serve_forever() 
        from gevent.pywsgi import WSGIServer
        WSGIServer((host, port), app, log=None).serve_forever()
    elif name =="bjoern":
        import bjoern
        bjoern.listen(app, host, port)
        bjoern.run() 
    elif name =="eventlet":
        import eventlet
        from eventlet import wsgi
        #worker_pool = eventlet.GreenPool(2000)
        #wsgi.server(eventlet.listen(('', port)), app, custom_pool=worker_pool, log=file('/dev/null', 'w'))
        # max_size
        wsgi.server(eventlet.listen(('', port)), app, max_size=10000, log=file('/dev/null', 'w'))
    elif name =="fapws":
        import fapws._evwsgi as evwsgi
        from fapws import base
        evwsgi.start(host, str(port)) 
        evwsgi.set_base_module(base)
        evwsgi.wsgi_cb(('/', app))
        evwsgi.set_debug(0)        
        evwsgi.run()
    elif name=="uwsgi":
        print ("""Enter this command in the console
                \nsudo uwsgi --http :8000 --master --disable-logging --pythonpath /home/a/g --wsgi-file w.py --listen 2  --buffer-size 2048 --async 10000 --ugreen -p 4
            """)
        #  http://osdir.com/ml/python-wsgi-uwsgi-general/2011-02/msg00136.html
        # 
        #  Re: strange SIGPIPE: writing to a closed pipe/socket/fd on image requested from facebook -msg#00136
        """
SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /1 (ip 127.0.0.1) !!!
uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 260]
IOError: write error
        """
        cmd_txt = "sudo uwsgi --http :8000 --master --harakiri 1 --harakiri-verbose --close-on-exec --disable-logging --pythonpath /home/a/todo/test --wsgi-file w2.py --listen 2  --buffer-size 2048 --async 10000 --ugreen -p 4"
        cmd(cmd_txt)
    elif name=="pycgi":
        from wsgiref.handlers import CGIHandler 
        CGIHandler().run(app)
    elif name=="pystandard":
        from wsgiref.simple_server import make_server
        make_server(host, port, app).serve_forever()
开发者ID:guguncube,项目名称:python-presentation,代码行数:52,代码来源:wsgi-benchmark.py


示例17: test_getpeername

def test_getpeername():

    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        s.connect(("localhost", 8000))
        assert(s)
        host, port = s.getpeername()
        assert(host == "127.0.0.1")
        assert(port == 8000)
        server.shutdown()

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


示例18: test_sockname

def test_sockname():

    def _test():
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        shost, sport = s.getsockname()
        ms = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        host, port = ms.getsockname()
        assert(host == shost)
        assert(port == sport)
        server.shutdown()

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


示例19: test_recvfrom

def test_recvfrom():

    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        s.connect(("localhost", 8000))
        s.send(b"GET / HTTP/1.0\r\n")
        s.send(b"\r\n")
        c, addr = s.recvfrom(1024)
        assert(len(c) == 135)

        server.shutdown()

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


示例20: test_recv_into

def test_recv_into():

    def _test():
        s = msocket.socket(msocket.AF_INET, msocket.SOCK_STREAM)
        s.connect(("localhost", 8000))
        s.send(b"GET / HTTP/1.0\r\n")
        s.send(b"\r\n")
        buf = array.array('b', [0] *1024)
        r = s.recv_into(buf)
        assert(r == 135)

        server.shutdown()

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python server.run函数代码示例发布时间:2022-05-27
下一篇:
Python mega.Mega类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap