Listeneres should be removed even in exception cases. Do a 'finally' cleanup.
This commit is contained in:
1 parent
01bdd1e4fa
commit
483f5c14ee
1 file changed
+10
-9
@@ -145,14 +145,15 @@ def search_params(evaluator, param):
|
|||||||
listener = ParamListener()
|
listener = ParamListener()
|
||||||
func.listeners.add(listener)
|
func.listeners.add(listener)
|
||||||
|
|
||||||
result = []
|
try:
|
||||||
# This is like backtracking: Get the first possible result.
|
result = []
|
||||||
for mod in imports.get_modules_containing_name([current_module], func_name):
|
# This is like backtracking: Get the first possible result.
|
||||||
result = get_params_for_module(mod)
|
for mod in imports.get_modules_containing_name([current_module], func_name):
|
||||||
if result:
|
result = get_params_for_module(mod)
|
||||||
break
|
if result:
|
||||||
|
break
|
||||||
# cleanup: remove the listener; important: should not stick.
|
finally:
|
||||||
func.listeners.remove(listener)
|
# cleanup: remove the listener; important: should not stick.
|
||||||
|
func.listeners.remove(listener)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
Reference in new issue
Block a user