Hey everyone. I am writing a threaded server and want to check if the the handler thread is being told to exit. I have code like so:
So my main thread will call thread.stop() when it wants to exit. I just want statusCheck() to run every few seconds to check if the thread should exit and if the connection with the client is still good. Is this code ok?Code:def __init__(self,...,..): self.timer = threading.Event() def stop(self): self.event.set() def statusCheck(self): if self.event.isSet(): self.exit() self.timer = threading.Timer(10, self.statusCheck) self.timer.start() def recvMsgs(self): self.timer = threading.Timer(10, self.statusCheck) self.timer.start() do stuff....
On another note, how can you determine if a client has closed their end of the socket?


LinkBack URL
About LinkBacks




Reply With Quote

Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum