From 2948be3af67b7ec124942654dc7f734eec346f55 Mon Sep 17 00:00:00 2001 From: Akshay Modi Date: Wed, 4 Apr 2018 14:41:59 -0700 Subject: [PATCH] Check that the c_api module is not destroyed PiperOrigin-RevId: 191649662 --- tensorflow/python/framework/c_api_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tensorflow/python/framework/c_api_util.py b/tensorflow/python/framework/c_api_util.py index 6c522de..4356a53 100644 --- a/tensorflow/python/framework/c_api_util.py +++ b/tensorflow/python/framework/c_api_util.py @@ -33,7 +33,7 @@ class ScopedTFStatus(object): def __del__(self): # Note: when we're destructing the global context (i.e when the process is # terminating) we can have already deleted other modules. - if c_api.TF_DeleteStatus is not None: + if c_api is not None and c_api.TF_DeleteStatus is not None: c_api.TF_DeleteStatus(self.status) @@ -46,7 +46,7 @@ class ScopedTFGraph(object): def __del__(self): # Note: when we're destructing the global context (i.e when the process is # terminating) we can have already deleted other modules. - if c_api.TF_DeleteGraph is not None: + if c_api is not None and c_api.TF_DeleteGraph is not None: c_api.TF_DeleteGraph(self.graph) @@ -59,7 +59,7 @@ class ScopedTFImportGraphDefOptions(object): def __del__(self): # Note: when we're destructing the global context (i.e when the process is # terminating) we can have already deleted other modules. - if c_api.TF_DeleteImportGraphDefOptions is not None: + if c_api is not None and c_api.TF_DeleteImportGraphDefOptions is not None: c_api.TF_DeleteImportGraphDefOptions(self.options) -- 2.7.4