'Persist the current in-memory list of config_elems to a file named by the
value of config_filename.'

def config_elems_to_xml_file(self, config_elems, config_filename, tool_path):

    lock = threading.Lock()
    lock.acquire(True)
    try:
        fh = open(config_filename, 'wb')
        fh.write(('<?xml    version="1.0"?>\n<toolbox    tool_path="%s">\n' % str(tool_path)))
        for elem in config_elems:
            fh.write(xml_util.xml_to_string(elem, use_indent=True))
        fh.write('</toolbox>\n')
        fh.close()
    except Exception:
        log.exception('Exception    in    ToolPanelManager.config_elems_to_xml_file')
    finally:
        lock.release()
