本文整理汇总了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
示例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)
示例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()
示例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)
示例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())
示例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())
示例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())
示例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())
示例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())
示例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())
示例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))
示例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())
示例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())
示例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
示例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())