def stop_server(self, port=None,pid=None):
if port and pid:
logger.warn("this function requires EITHER a port OR a pid, ignores pid if both")
if port:
instance = [instance for instance in self.instances if instance['port']==port]
elif pid:
instance = [instance for instance in self.instances if instance['pid']==pid]
else:
instance = self.instances
if not instance:
logger.warn("Instance not found!")
return False
instance = instance[0]
os.killpg(instance['instance'].pid, 15)
time.sleep(1)
if not check_exists(instance['port']):
logger.info('Stopped {pid} instance at port {port}'.format(**instance))
self.instances.remove(instance)
return True
else:
logger.warn('Unable to stop {pid} instance running at {port}!!'.format(**instance))
return False
senti_client.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录