def send_data(self): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock_l = [s] s.connect((self.host, self.port)) except socket.error as err: print err while 1: print "send data to %s %s" %(self.host, self.port) if not self.queue.empty(): data = self.queue.get() sendData(sock_l, self.host, self.port, json.dumps(data)) print data, "q size is: ", self.queue.qsize() time.sleep(self.interval)
def sendMonitorData(self): data = self.readData() sendData(self.sock_l, self.host, self.port, data)