瀏覽代碼

utils/kamctl: dbtextdb.py close previous opened file properly

related #1747

(cherry picked from commit 5f52f9905bbdf63d636080f7d0340af4f71ed12a)
(cherry picked from commit e26e587f31eb23c431a2cfb149ec7a86b4f648bc)
Victor Seva 5 年之前
父節點
當前提交
4061a1d7cd
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      utils/kamctl/dbtextdb/dbtextdb.py

+ 6 - 0
utils/kamctl/dbtextdb/dbtextdb.py

@@ -60,6 +60,10 @@ class DBText(object):
         if not os.path.isdir(location):
             raise ParseError(location + ' is not a directory')
 
+    def __del__(self):
+        if getattr(self, 'fd', False):
+            self.fd.close()
+
     def _ParseOrderBy(self):
         """Parse out the column name to be used for ordering the dataset.
 
@@ -438,6 +442,8 @@ class DBText(object):
         self.command = ''     # which command are we executing
         self.strings = []     # list of string literals parsed from the query
         self.parens = []      # list of parentheses parsed from the query
+        if getattr(self, 'fd', False):
+            self.fd.close()
 
     def ParseQuery(self, query):
         """External wrapper for the query parsing routines.