From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 043BC13C695 for ; Thu, 8 May 2025 13:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746712025; cv=none; b=WGIUamHY2MsPsGk4RDmq3byJ1AWa9jPXGsw9izrb85Fjz+09EwZ00VnWnHmUaSfNu2pCJLH3lACwPOFI6eOSkRSj+0+kOu1YbzS5IB7K8sejwOaUG90raKD6a8ABCHDxCrCbM56vqgIac1rinh5wfdB+k//IZCo+RErRwQ7FEJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746712025; c=relaxed/simple; bh=kJDvjeDaSauDK6hVzmuzind8TuNrUUe75gumjgqPvZQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BtocvL9VvseMg/hWXGah4YoZnE3d0jP+idE2de3q/BwkltfMscgOEX7ac8l5+TYH4Us7MwRW0Cpv7KB3iyTEzK4XWJVzPqYm9DefkixJG9OI696at6ZxqDfDmybzqac9GrUwqBpm0463po0o9bpCLpezIb+oVjBklCw2VIAn9AM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y0SMHTTw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y0SMHTTw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FF29C4CEE7; Thu, 8 May 2025 13:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746712024; bh=kJDvjeDaSauDK6hVzmuzind8TuNrUUe75gumjgqPvZQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Y0SMHTTwTN0xp+LG7sUKplwaGZmIoWuAggbbNQln/zAs7KJP4FVvK79iDHPCCymiL JTWBu9oKaoCVdRnUKGdrDI8ndEiJnWC9X2YN7zgj5AOjKaoHWTUiQzEd/yzGzKnxJZ CS6WFIz60sip6xoBT2FizPIRVHBdHybF0pYLP8IdASUlvz52qtOER9Res7a+xW2e8O pQb2hV6xUYLRsycXECC7nyR+OPJmqceomG9IlBhOH2wyQskmu2u/mfz/TDwmO9o7gW 1MkEWzy81vRMDj/jaV8V8z/C2YrSH+Q6sh3mg57Be8d4WM8u/+FvnbrtvxWOndwLnA qiWYnGqyi9rqA== Date: Thu, 8 May 2025 06:47:03 -0700 From: Jakub Kicinski To: Donald Hunter Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jan Stancek , donald.hunter@redhat.com Subject: Re: [PATCH net-next v1] tools: ynl: handle broken pipe gracefully in CLI Message-ID: <20250508064703.5d488277@kernel.org> In-Reply-To: <20250508112102.63539-1-donald.hunter@gmail.com> References: <20250508112102.63539-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 8 May 2025 12:21:02 +0100 Donald Hunter wrote: > When sending YNL CLI output into a pipe, closing the pipe causes a > BrokenPipeError. E.g. running the following and quitting less: > > ./tools/net/ynl/pyynl/cli.py --family rt-link --dump getlink | less > Traceback (most recent call last): > File "/home/donaldh/net-next/./tools/net/ynl/pyynl/cli.py", line 160, in > main() > ~~~~^^ > File "/home/donaldh/net-next/./tools/net/ynl/pyynl/cli.py", line 142, in main > output(reply) > ~~~~~~^^^^^^^ > File "/home/donaldh/net-next/./tools/net/ynl/pyynl/cli.py", line 97, in output > pprint.PrettyPrinter().pprint(msg) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^ > [...] > BrokenPipeError: [Errno 32] Broken pipe > > Consolidate the try block for ops and notifications, and gracefully > handle the BrokenPipeError by adding an exception handler to the > consolidated try block. Reviewed-by: Jakub Kicinski