From 5d4ec1ab9ed65015e70a6ddf7027a310f4ad66ac Mon Sep 17 00:00:00 2001 From: lantz Date: Sun, 7 Feb 2021 19:12:38 -0800 Subject: [PATCH] catch IOError when writing .mininet_history (#1031) write_history seems to raise a spurious IOError, so we catch it. --- mininet/cli.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mininet/cli.py b/mininet/cli.py index 82e2ac5..ce5bcdc 100644 --- a/mininet/cli.py +++ b/mininet/cli.py @@ -89,7 +89,15 @@ class CLI( Cmd ): if os.path.isfile( history_path ): read_history_file( history_path ) set_history_length( 1000 ) - atexit.register( lambda: write_history_file( history_path ) ) + + def writeHistory(): + "Write out history file" + try: + write_history_file( history_path ) + except IOError: + # Ignore probably spurious IOError + pass + atexit.register( writeHistory ) def run( self ): "Run our cmdloop(), catching KeyboardInterrupt"