python - client connects to old server thread and retrieves outdated data? -


i have client thread ping server 1 of status attributes:

    def run ( self ):      client = socket.socket(socket.af_inet, socket.sock_stream)     client.connect(('localhost',2727))      print 'client #', self.name , 'polling'      x = client.recv(1024)     client.close()      print x 

my server runs loop gets it's state, , spawns thread socket:

    while true:          devicestate = self.getdevicestate()         channel, details = self.server.accept()         sthread.serverthread(channel, details, devicestate).start() 

the issue after update devicestate , client pings, first gets old state (probably existing serverthread) no matter how long wait. when client pings again, can pick new state. there way shutdown serverthread if devicestate updated , make sure client socket gets fresh server thread?

sthread.serverthread() function, right?

instead of getting device state , passing argument serverthread(), have implementation of serverthread() call .getdevicestate() after request comes in latest device state.

the way have set returns device state when thread created, not device state when request comes in.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -