def _remove_existed_sock(self, sock_file): if os.path.exists(sock_file): mode = os.stat(sock_file).st_mode if stat.S_ISSOCK(mode): os.remove(sock_file)