Threading.Lock() question
Alvin A. Delagon
adelagon at gmail.com
Thu Mar 9 11:13:33 EST 2006
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 "Segmentation 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(threading.Thread):
def __init__(self,lock,query)
self.lock = lock
self.query = query
threading.Thread.__init__(self)
def run(self):
''' Some data processing code here '''
self.lock.acquire()
result = cursor.execute(query)
self.lock.release()
class Send(Request__POA.Send):
def push(self,query,...some args here):
lock = threading.Lock()
Process(lock,query).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!
More information about the Python-list
mailing list