senti_client.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:SentiStrength_for_python 作者: bobvdvelde 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号