Detaching sometimes throws ValueError: I/O operation on closed file. ptvsd:1165
@@ -1596,8 +1596,17 @@ class PyDB(object):
return globals
def exiting(self):
+ # Either or both standard streams can be closed at this point,
+ # in which case flush() will fail.
+ try:
sys.stdout.flush()
+ except:
+ pass
+ try:
sys.stderr.flush()
+ except:
+ pass
+
self.check_output_redirect()
cmd = self.cmd_factory.make_exit_message()
self.writer.add_command(cmd)
