def teardown(self, exception):
ctx = stack.top<EOL>if ctx is not None:<EOL><INDENT>if hasattr(ctx, '<STR_LIT>'):<EOL><INDENT>for connection in ctx.ldap3_manager_connections:<EOL><INDENT>self.destroy_connection(connection)<EOL><DEDENT><DEDENT>if hasattr(ctx, '<STR_LIT>'):<EOL><INDENT>log.debug(<EOL>"<STR_LIT>")<EOL>ctx.ldap3_manager_main_connection.unbind()<EOL>ctx.ldap3_manager_main_connection = None<EOL><DEDENT><DEDENT>
Cleanup after a request. Close any open connections.