None type object cannot call close (#143)

* Fix AttributeError in file.close
This commit is contained in:
Jeff 2021-08-04 02:28:03 +08:00 committed by GitHub
parent eeaf5b5963
commit 68733314f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,7 +117,8 @@ class TrainingLogWriter(object):
self.file.flush()
def close(self):
self.file.close()
if self.file is not None:
self.file.close()
self.file = None # for pickle
@ -141,7 +142,8 @@ class TrainingLogReader(object):
yield TrainingLogRecord(**data)
def close(self):
self.file.close()
if self.file is not None:
self.file.close()
self.file = None # for pickle
def get_record(self, record_id) -> TrainingLogRecord: