def send_message(loop): while True: while outboundMessageQueue.qsize() > 0: print("sending a message") #HOSTID, IP ADDRESS, PORT message_dests = getDests() #message dests should now be a dictionary that has the host IP address as the key, and a list as the data if outboundMessageQueue.qsize() > 0 : msg = outboundMessageQueue.get_nowait() # print("MESSAGE TO " ,msg.destID) # print("EEEEVO:", message_dests) message_dests[str(msg.destID)][1].append(msg) # print(msg) for dest in message_dests: # print("INDIVID DST:", dest) if len(message_dests[str(dest)]) is 0: pass else: # print(str(message_dests[str(dest)][0])) #reader,writer = yield from asyncio.open_connection(deststr, loop=loop) # # print("DEESSST TEST", dest) for mess in message_dests[str(dest)][1]: # print("MEEEEESSSS:", mess) #mess = pickle.dumps(mess) x = mess.toJSON() # print(x) y = algHelper.messageFromJSON(x) # print("y is: ", y) yield from threadWriter(message_dests[str(dest)][0],x,loop) #writer.write(jsonpickle.encode(msg).encode()) # print("send message ran.") yield from asyncio.sleep(1)
def handle_message(reader, writer): # print("COG RCV MESSAGE") data = yield from reader.read() message = data.decode() addr = writer.get_extra_info("peername") decoded = algHelper.messageFromJSON(message) x = decoded # print("Received %r from %r" % (decoded, addr)) # x = pickle.loads(data) # x = pickle.decode(message) # print("JSON DE-PICKLED IS %s", x) # writer.close() inboundMessageQueue.put_nowait(decoded) theProc = yield from processQueue.get() x = theProc.recvMsg(x) y = yield from testCallback() processQueue.put_nowait(theProc) print("*****Completed message receive.*****")
def handle_message(reader,writer): # print("COG RCV MESSAGE") data = yield from reader.read() message = data.decode() addr = writer.get_extra_info('peername') decoded = algHelper.messageFromJSON(message) x = decoded # print("Received %r from %r" % (decoded, addr)) #x = pickle.loads(data) #x = pickle.decode(message) #print("JSON DE-PICKLED IS %s", x) #writer.close() inboundMessageQueue.put_nowait(decoded) theProc = yield from processQueue.get() x = theProc.recvMsg(x) y = yield from testCallback() processQueue.put_nowait(theProc) print("*****Completed message receive.*****")
def send_message(loop): while True: while outboundMessageQueue.qsize() > 0: print("sending a message") # HOSTID, IP ADDRESS, PORT message_dests = getDests() # message dests should now be a dictionary that has the host IP address as the key, and a list as the data if outboundMessageQueue.qsize() > 0: msg = outboundMessageQueue.get_nowait() # print("MESSAGE TO " ,msg.destID) # print("EEEEVO:", message_dests) message_dests[str(msg.destID)][1].append(msg) # print(msg) for dest in message_dests: # print("INDIVID DST:", dest) if len(message_dests[str(dest)]) is 0: pass else: # print(str(message_dests[str(dest)][0])) # reader,writer = yield from asyncio.open_connection(deststr, loop=loop) # # print("DEESSST TEST", dest) for mess in message_dests[str(dest)][1]: # print("MEEEEESSSS:", mess) # mess = pickle.dumps(mess) x = mess.toJSON() # print(x) y = algHelper.messageFromJSON(x) # print("y is: ", y) yield from threadWriter(message_dests[str(dest)][0], x, loop) # writer.write(jsonpickle.encode(msg).encode()) # print("send message ran.") yield from asyncio.sleep(1)