I have a multithreaded application that spawns threads which query a
database server. During stress test I encountered some threads failing
due "lost connection errors" and sometimes the actual script itself dies
due to a "Segmentati on Fault". I realized that it might be a deadlock
situation so I applied a lock mechanism but after another stress test,
some threads are still failing. Here's a rough sketch of my script:
class Process(threadi ng.Thread):
def __init__(self,l ock,query)
self.lock = lock
self.query = query
threading.Threa d.__init__(self )
def run(self):
''' Some data processing code here '''
self.lock.acqui re()
result = cursor.execute( query)
self.lock.relea se()
class Send(Request__P OA.Send):
def push(self,query ,...some args here):
lock = threading.Lock( )
Process(lock,qu ery).start()
db = MySQL().connect ()
cursor = db.make_cursor( )
The class Send is being called by a CORBA client. The script is actually
a CORBA server which in the future would serve a high traffic of
requests. Is my usage is locking correct or am I doing something stupid
in the code? Thanks is advance!
database server. During stress test I encountered some threads failing
due "lost connection errors" and sometimes the actual script itself dies
due to a "Segmentati on Fault". I realized that it might be a deadlock
situation so I applied a lock mechanism but after another stress test,
some threads are still failing. Here's a rough sketch of my script:
class Process(threadi ng.Thread):
def __init__(self,l ock,query)
self.lock = lock
self.query = query
threading.Threa d.__init__(self )
def run(self):
''' Some data processing code here '''
self.lock.acqui re()
result = cursor.execute( query)
self.lock.relea se()
class Send(Request__P OA.Send):
def push(self,query ,...some args here):
lock = threading.Lock( )
Process(lock,qu ery).start()
db = MySQL().connect ()
cursor = db.make_cursor( )
The class Send is being called by a CORBA client. The script is actually
a CORBA server which in the future would serve a high traffic of
requests. Is my usage is locking correct or am I doing something stupid
in the code? Thanks is advance!