提供gevent原语来将不同的正交服务器和服务编排在一起。
biloba的Python项目详细描述
就像银杏树一样(这一模块的灵感来自于银杏树)。将gevent原语提供给 将不同的正交服务器和服务编排在一起。
基本用法:
from gevent import wsgi import biloba def hello_world(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) return ['<b>Hello world!</b>\n'] class MyService(biloba.Service): def make_web_server(self): return wsgi.WSGIServer( ('localhost', 5000), hello_world ) def do_start(self): self.web_server = self.make_web_server() self.spawn(self.web_server.serve_forever) # you can add more servers/services here if __name__ == '__main__': my_service = MyService() # start is called by join try: my_service.join() except KeyboardInterrupt: pass # as is stop
扩展名
Biloba支持扩展。将模块定义为biloba_foobar并导入 biloba.ext.foobar将起作用。