From b7e181e25bc69705e43ad31ebce29af432562b4a 2023-02-04 10:16:21 From: Roy Reznik Date: 2023-02-04 10:16:21 Subject: [PATCH] Fix bug when network map is disconnected --- diff --git a/IPython/core/logger.py b/IPython/core/logger.py index e3cb233..99e7ce2 100644 --- a/IPython/core/logger.py +++ b/IPython/core/logger.py @@ -198,7 +198,16 @@ which already exists. But you must first start the logging process with odata = u'\n'.join([u'#[Out]# %s' % s for s in data.splitlines()]) write(u'%s\n' % odata) - self.logfile.flush() + try: + self.logfile.flush() + except OSError: + print("Failed to flush the log file.") + print( + f"Please check that {self.logfname} exists and have the right permissions." + ) + print( + "Also consider turning off the log with `%logstop` to avoid this warning." + ) def logstop(self): """Fully stop logging and close log file.