sockets - keep python script running wile also waiting for a tcp connection -
is way of making python script keep looping running wile waiting tcp connection or message coming in via tcp.
i have produced "program" run stand alone able control via tcp connection. have main part of program running when adding tcp control python script pauses @ either part waiting tcp connection or message come script via tcp. there way around this?
s.listen(0) conn, addr = s.accept() print('connected by', addr) #-------------------------loop start---------------------------------------- while continue_reading: print 'help 1' doc = minidom.parse(folder + file) card = doc.getelementsbytagname("card") #------------ip stuff--------------- data = conn.recv(1024) if data: print 'help 2' if data == "theme?": itemlist = doc.getelementsbytagname('card') conn.send(str(len(itemlist))+"\r\n") x in itemlist: xcard = x.attributes['id'].value xname = x.getelementsbytagname("name")[0] xfname = xname.firstchild.data conn.send(xcard+" - "+xfname+"\r\n") elif data == "running?": print"running?" conn.send(uid2 +" - "+fname+ "\r\n") #----------------rest of program runs below line working fine-----------
Comments
Post a Comment