@@ -79,19 +79,21 @@ def close(self):
7979 """
8080 Close the connector and release resources.
8181 """
82- if self ._hook_dir :
83- self ._hook_dir = ''
82+ try :
83+ if self ._hook_dir :
84+ self ._hook_dir = ''
8485
85- if builtins .open == self ._connector_open :
86- builtins .open = self ._origin_open
87- torch .UntypedStorage .from_file = self ._origin_from_file
86+ if builtins .open == self ._connector_open :
87+ builtins .open = self ._origin_open
8888
89- if torch .UntypedStorage .from_file == self ._from_file_helper :
90- torch .UntypedStorage .from_file = self ._origin_from_file
89+ if torch .UntypedStorage .from_file == self ._from_file_helper :
90+ torch .UntypedStorage .from_file = self ._origin_from_file
9191
92- if self ._real_connector is not None :
93- del self ._real_connector
94- self ._real_connector = None
92+ if self ._real_connector is not None :
93+ del self ._real_connector
94+ self ._real_connector = None
95+ except :
96+ print ("exception in close, ignore" )
9597
9698 def open (self , uri , binary = True ):
9799 """
@@ -116,8 +118,7 @@ def _from_file_helper(self, filename, shared, nbytes):
116118 def _connector_open (self , file , mode = 'r' , buffering = - 1 , encoding = None , errors = None , newline = None , closefd = True , opener = None ):
117119 if isinstance (file , pathlib .Path ):
118120 file = str (file )
119-
120- if self ._hook_dir and isinstance (file , str ) and file .startswith (self ._hook_dir ):
121+ if self ._hook_dir and file .startswith (self ._hook_dir ):
121122 binary = False
122123 if 'b' in mode :
123124 binary = True
0 commit comments