def sending(queue,ADDR_SENDING,lock,commandqueue): net = NetworkUDP(ADDR_SENDING) #print queue while True: #print 'this is sending' sleep(0.1) #print "sending Thread" if lock.acquire(1) == True: if queue.empty() == False: msg = queue.get() lock.release() #print "sending ",msg if net.sending(msg[0], msg[1]) == False: #print "send",msg,"failed" #lock.release() print "Lost Connection From the Server" commandqueue.put("reset-all") #print "Send Success",msg if msg[0][0] == '@': break else: lock.release() return
def sending(queue,ADDR_SENDING,commandqueue): net = NetworkUDP(ADDR_SENDING) while True: msg = queue.get() #print "sending ",msg if net.sending(msg[0], msg[1])==False: print "send",msg,"failed" cmd = ["disconnect",str(msg[1][0]),str(msg[1][1])] cmd = " ".join(cmd) commandqueue.put(cmd) else: print "Send Success",msg if msg[0][0] == '@': break return