From e88e23cad2581435064b5c2cc40baab3eccb617f Mon Sep 17 00:00:00 2001 From: wuzewu Date: Fri, 21 Feb 2020 20:56:43 +0800 Subject: [PATCH] Fix crash caused by repeatedly creating Module --- paddlehub/module/module.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/paddlehub/module/module.py b/paddlehub/module/module.py index 59d52f94..44b97fbb 100644 --- a/paddlehub/module/module.py +++ b/paddlehub/module/module.py @@ -135,9 +135,6 @@ def runnable(func): class Module(object): - - _record = {} - def __new__(cls, name=None, directory=None, @@ -180,9 +177,8 @@ class Module(object): version=None, **kwargs): # Avoid module being initialized multiple times - if not directory or id(self) in Module._record: + if "_is_initialize" in self.__dict__ and self._is_initialize: return - Module._record[id(self)] = True mod = self.__class__.__module__ + "." + self.__class__.__name__ if mod in _module_runnable_func: @@ -212,6 +208,7 @@ class Module(object): module_info.map.data['summary']) self._initialize(**kwargs) + self._is_initialize = True @classmethod def init_with_name(cls, name, version=None, **kwargs): -- GitLab