File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
prompt_toolkit/contrib/telnet Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,8 @@ def isatty(self) -> bool:
99
99
100
100
def flush (self ) -> None :
101
101
try :
102
- self ._connection .send (b"" .join (self ._buffer ))
102
+ if not self ._closed :
103
+ self ._connection .send (b"" .join (self ._buffer ))
103
104
except OSError as e :
104
105
logger .warning ("Couldn't send data over socket: %s" % e )
105
106
@@ -355,6 +356,15 @@ async def run() -> None:
355
356
finally :
356
357
self .connections .remove (connection )
357
358
logger .info ("Stopping interaction %r %r" , * addr )
359
+ except EOFError :
360
+ # Happens either when the connection is closed by the client
361
+ # (e.g., when the user types 'control-]', then 'quit' in the
362
+ # telnet client) or when the user types control-d in a prompt
363
+ # and this is not handled by the interact function.
364
+ logger .info ("Unhandled EOFError in telnet application." )
365
+ except KeyboardInterrupt :
366
+ # Unhandled control-c propagated by a prompt.
367
+ logger .info ("Unhandled KeyboardInterrupt in telnet application." )
358
368
except BaseException as e :
359
369
print ("Got %s" % type (e ).__name__ , e )
360
370
import traceback
You can’t perform that action at this time.
0 commit comments