easy_application.py 文件源码

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

项目:ops_agent 作者: sjqzhang 项目源码 文件源码
def bind_unix_listener(self, path, backlog=50, user=None):
        try:
            sock = gevent.socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            sock.setblocking(0)
            self.unlink(path)
            sock.bind(path)
            if user is not None:
                import pwd
                user = pwd.getpwnam(user)
                os.chown(path, user.pw_uid, user.pw_gid)
            os.chmod(path, 0777)
            sock.listen(backlog)
        except Exception, e:
            self.logger.error("Create unix socket failed: %s", e.__str__())
            return None
        return sock
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号