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 from io import BufferedIOBase
import logging
import os import os
import sys import sys
_logger = logging.getLogger(__name__)
if sys.platform == 'win32': if sys.platform == 'win32':
import _winapi import _winapi
import msvcrt import msvcrt
...@@ -29,8 +32,11 @@ if sys.platform == 'win32': ...@@ -29,8 +32,11 @@ if sys.platform == 'win32':
return self.file return self.file
def close(self) -> None: def close(self) -> None:
if self.file is not None: try:
self.file.close() if self.file is not None:
self.file.close()
except Exception as e:
_logger.debug('Error on closing Windows pipe: %s', e)
Pipe = WindowsPipe Pipe = WindowsPipe
...@@ -55,9 +61,12 @@ else: ...@@ -55,9 +61,12 @@ else:
return self.file return self.file
def close(self) -> None: def close(self) -> None:
if self.file is not None: try:
self.file.close() if self.file is not None:
self._socket.close() self.file.close()
os.unlink(self.path) self._socket.close()
os.unlink(self.path)
except Exception as e:
_logger.debug('Error on closing POSIX pipe: %s', e)
Pipe = UnixPipe 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