def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def close(self):
        time.sleep(0.1)
        self.sock.close()
        return 0