Skip to content

cli: webservice logs -f: Don't spam user w/ stack trace on control-C

Ahmon Dancy requested to merge main-I5d58c8a698412e881b88e112aec6d3df16b6e534 into main

Before:

$ toolforge webservice logs -f  
<log output>  
^C  
Traceback (most recent call last):  
  File "/usr/bin/toolforge-webservice", line 33, in <module>  
Aborted!  
    sys.exit(load_entry_point('toolforge-webservice==0.103.5', 'console_scripts', 'toolforge-webservice')())  
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "/usr/lib/python3/dist-packages/toolsws/cli/webservice.py", line 602, in main  
    for entry in logs:  
  File "/usr/lib/python3/dist-packages/toolforge_weld/logs/kubernetes.py", line 66, in query  
    for entry in self._get_pod_logs(  
  File "/usr/lib/python3/dist-packages/toolforge_weld/logs/kubernetes.py", line 33, in _get_pod_logs  
    for line in self.client.get_raw_lines(  
  File "/usr/lib/python3/dist-packages/toolforge_weld/api_client.py", line 173, in get_raw_lines  
    yield from r.iter_lines(decode_unicode=True)  
  File "/usr/lib/python3/dist-packages/requests/models.py", line 865, in iter_lines  
    for chunk in self.iter_content(  
  File "/usr/lib/python3/dist-packages/requests/utils.py", line 566, in stream_decode_response_unicode  
    for chunk in iterator:  
  File "/usr/lib/python3/dist-packages/requests/models.py", line 816, in generate  
    yield from self.raw.stream(chunk_size, decode_content=True)  
  File "/usr/lib/python3/dist-packages/urllib3/response.py", line 623, in stream  
    for line in self.read_chunked(amt, decode_content=decode_content):  
  File "/usr/lib/python3/dist-packages/urllib3/response.py", line 815, in read_chunked  
    self._update_chunk_length()  
  File "/usr/lib/python3/dist-packages/urllib3/response.py", line 745, in _update_chunk_length  
    line = self._fp.fp.readline()  
           ^^^^^^^^^^^^^^^^^^^^^^  
  File "/usr/lib/python3.11/socket.py", line 706, in readinto  
    return self._sock.recv_into(b)  
           ^^^^^^^^^^^^^^^^^^^^^^^  
  File "/usr/lib/python3.11/ssl.py", line 1278, in recv_into  
    return self.read(nbytes, buffer)  
           ^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "/usr/lib/python3.11/ssl.py", line 1134, in read  
    return self._sslobj.read(len, buffer)  
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
KeyboardInterrupt  

After:

$ toolforge webservice logs -f  
<log output>  
^C  
Interrupted  

Bug: T361437

Edited by Ahmon Dancy

Merge request reports