mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix funky errors by explicitly destroying the global variable at exit time
This commit is contained in:
parent
331bdb53aa
commit
08dc22b750
1 changed files with 12 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
"""
|
||||
|
||||
import atexit
|
||||
from moulinette.core import init_authenticator
|
||||
|
||||
# We use a global variable to do some caching
|
||||
|
@ -38,3 +39,14 @@ def _get_ldap_interface():
|
|||
_ldap_interface = init_authenticator(AUTH_IDENTIFIER, AUTH_PARAMETERS)
|
||||
|
||||
return _ldap_interface
|
||||
|
||||
# Add this to properly close / delete the ldap interface / authenticator
|
||||
# when Python exits ...
|
||||
# Otherwise there's a risk that some funky error appears at the very end
|
||||
# of the command due to Python stuff being unallocated in wrong order.
|
||||
def _destroy_ldap_interface():
|
||||
global _ldap_interface
|
||||
if _ldap_interface is not None:
|
||||
del _ldap_interface
|
||||
|
||||
atexit.register(_destroy_ldap_interface)
|
||||
|
|
Loading…
Add table
Reference in a new issue