def writeservers(self):
        ''' Write the server list to a text file in the session directory upon
        startup: /tmp/pycore.nnnnn/servers
        '''
        filename = os.path.join(self.session.sessiondir, "servers")
        try:
            f = open(filename, "w")
            master = self.session_id_master
            if master is None:
                master = self.session.sessionid
            f.write("master=%s\n" % master)
            self.servers_lock.acquire()
            for name in sorted(self.servers.keys()):
                if name == "localhost":
                    continue
                (host, port, sock) = self.servers[name]
                try:
                    (lhost, lport) = sock.getsockname()
                except:
                    lhost, lport = None, None
                f.write("%s %s %s %s %s\n" % (name, host, port, lhost, lport))
            f.close()
        except Exception, e:
            self.session.warn("Error writing server list to the file: %s\n%s" \
                        % (filename, e))
        finally:
            self.servers_lock.release()
dataset/ETHPy150Open coreemu/core/daemon/core/broker.py/CoreBroker.writeservers/original