本文整理汇总了Python中server.Server.close方法的典型用法代码示例。如果您正苦于以下问题:Python Server.close方法的具体用法?Python Server.close怎么用?Python Server.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server.Server
的用法示例。
在下文中一共展示了Server.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main_loop
# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import close [as 别名]
def main_loop(self):
exit_app = False
srv = Server()
while not exit_app:
self.lego = None
srv.accept()
while True:
data = srv.recv()
logging.info(data)
if not data:
del self.lego
break
elif data == 'start':
if not self.lego:
self.lego = Lego()
if self.lego.idle:
thread.start_new_thread(self.start_lego, ())
elif self.lego and data == 'stop':
self.lego.stop()
elif self.lego and data == 'reset':
self.lego.reset()
elif data == 'exit':
exit_app = True
del self.lego
break
srv.close()
示例2: main_loop
# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import close [as 别名]
def main_loop():
socket_fd, num_features, learning_type, model = sys.argv[1:5]
learner_klass = {'cluster': Clusterer, 'classify': Classifier}[learning_type]
parser = getattr(getattr(models, inflection.underscore(model)), model)
learner = learner_klass.empty(*map(int, num_features.split(',')))
server = Server(int(socket_fd), learner, parser.parse_raw)
backend = {'cluster': server.minibatch_kmeans_backend, 'classify': server.svc_backend}[learning_type]
try:
server.start(backend)
except StopIteration:
pass
finally:
server.close()