"examples/cpp_parse_load_save" did not exist on "cc2296f47196f0e879e109dee3c2375c29dcab85"
Unverified Commit c4d449c5 authored by liuzhe-lz's avatar liuzhe-lz Committed by GitHub
Browse files

Catch clean up error to prevent crash (#3729)


Co-authored-by: default avatarliuzhe <zhe.liu@microsoft.com>
parent 700026c5
from io import BufferedIOBase
import logging
import os
import sys
_logger = logging.getLogger(__name__)
if sys.platform == 'win32':
import _winapi
import msvcrt
......@@ -29,8 +32,11 @@ if sys.platform == 'win32':
return self.file
def close(self) -> None:
if self.file is not None:
self.file.close()
try:
if self.file is not None:
self.file.close()
except Exception as e:
_logger.debug('Error on closing Windows pipe: %s', e)
Pipe = WindowsPipe
......@@ -55,9 +61,12 @@ else:
return self.file
def close(self) -> None:
if self.file is not None:
self.file.close()
self._socket.close()
os.unlink(self.path)
try:
if self.file is not None:
self.file.close()
self._socket.close()
os.unlink(self.path)
except Exception as e:
_logger.debug('Error on closing POSIX pipe: %s', e)
Pipe = UnixPipe
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment