本文整理汇总了Python中wsgiref.simple_server.WSGIServer.server_close方法的典型用法代码示例。如果您正苦于以下问题:Python WSGIServer.server_close方法的具体用法?Python WSGIServer.server_close怎么用?Python WSGIServer.server_close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wsgiref.simple_server.WSGIServer
的用法示例。
在下文中一共展示了WSGIServer.server_close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: server_close
# 需要导入模块: from wsgiref.simple_server import WSGIServer [as 别名]
# 或者: from wsgiref.simple_server.WSGIServer import server_close [as 别名]
def server_close(self):
"""
Properly initiate closing handshakes on
all websockets when the WSGI server terminates.
"""
print "closing sockets"
_WSGIServer.server_close(self)
示例2: server_close
# 需要导入模块: from wsgiref.simple_server import WSGIServer [as 别名]
# 或者: from wsgiref.simple_server.WSGIServer import server_close [as 别名]
def server_close(self):
"""
Properly initiate closing handshakes on
all websockets when the WSGI server terminates.
"""
if hasattr(self, 'manager'):
self.manager.close_all()
self.manager.stop()
self.manager.join()
delattr(self, 'manager')
_WSGIServer.server_close(self)
示例3: _HTTPServer
# 需要导入模块: from wsgiref.simple_server import WSGIServer [as 别名]
# 或者: from wsgiref.simple_server.WSGIServer import server_close [as 别名]
class _HTTPServer(bottle.ServerAdapter):
"""
Reimplement bottle's WSGIRefServer. Override the request handler class and
add a stop() method for cleanly shutting down the server.
"""
srv = None
app = None
def run(self, handler):
# Handle the TIME_WAIT state for quick server restarts
WSGIServer.allow_reuse_address = 1
# Create the server and start it
self.srv = WSGIServer((self.host, self.port), _HTTPRequestHandler)
self.srv.set_app(self.app)
try:
self.srv.serve_forever()
finally:
self.srv.server_close()
def stop(self):
if self.srv:
self.srv.shutdown()