usertools: fix handling EOF for telemetry input pipe
To allow the script to take queries from input pipes e.g. "echo
/ethdev/stats,0 | dpdk-telemetry.py", we need to handle the case of EOF
correctly without crashing with an exception. Do this by using a
try-except block around the input handling.
Fixes: 6a2967c112
("usertools: add new telemetry script")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
This commit is contained in:
parent
ea3ef0b85f
commit
744e9a87c5
@ -69,13 +69,17 @@ def handle_socket(path):
|
||||
CMDS = read_socket(sock, output_buf_len, False)["/"]
|
||||
|
||||
# interactive prompt
|
||||
text = input('--> ').strip()
|
||||
while text != "quit":
|
||||
if text.startswith('/'):
|
||||
sock.send(text.encode())
|
||||
read_socket(sock, output_buf_len)
|
||||
try:
|
||||
text = input('--> ').strip()
|
||||
sock.close()
|
||||
while text != "quit":
|
||||
if text.startswith('/'):
|
||||
sock.send(text.encode())
|
||||
read_socket(sock, output_buf_len)
|
||||
text = input('--> ').strip()
|
||||
except EOFError:
|
||||
pass
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
||||
def readline_complete(text, state):
|
||||
|
Loading…
Reference in New Issue
Block a user