本文整理汇总了Python中meinheld.server.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: run
def run(self, handler):
from meinheld import server
if self.quiet:
server.set_access_logger(None)
server.set_error_logger(None)
server.listen((self.host, self.port))
server.run(handler)
示例3: 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)
示例4: 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())
示例5: 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())
示例6: run
def run(self):
fd = self.socket.fileno()
server.set_keepalive(self.cfg.keepalive)
server.set_picoev_max_fd(self.cfg.worker_connections)
server.set_fastwatchdog(self.tmp.fileno(), self.ppid, int(self.timeout))
#server.set_watchdog(self.watchdog)
server.set_listen_socket(fd)
server.run(self.wsgi)
示例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_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())
示例9: 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())
示例10: 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())
示例11: 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())
示例12: 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))
示例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: 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())
示例15: 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()