thread-(dead)lock
Thomas Thiele
thiele at muc.das-werk.de
Wed May 10 15:18:29 EDT 2000
I have a server (derived from mutithreading SocketServer.py) and a
client running on the same host, connectet via AF_INET-Socket.
The server creates for every request a new thread. So I have three
threads now. The main thread, a second thread that executes a
loop-function, in which my problematic function is called, and a third
thread created by a request from my client.
class Requesthandler:
def __init__(self):
.....
self.lock = thread.allocate_lock()
def Loop(self): #runs in one thread
time.sleep(self.updatetime)
self.ProblemFunction()
def ProblemFunction(self):
print "before aquire()"
self.lock.aquire()
print "locked"
....do something....
self.lock.release()
print "unlocked"
def HandelRequestFromClient(self): #runs in another thread
self.ProblemFunction()
.........
The client causes the server periodically to call its ProblemFunction()
too.
class Client:
def __init__(self):
.....
signal.signal(signal.SIGALRM, self.LoopSignalHandler)
signal.alarm(self.updatetime)
def LoopSignalHandler(self):
Cause_Server_to_execute_ProblemFunction()
........
My problem is, that it works for 20 minutes an then I have a deadlock.
"before aquire()" is printed and the function is blocked in both
threads.
The problem is not the "do something"-stuff!
Any ideas why?
Thanks Thomas
More information about the Python-list
mailing list