From: Robert B. <ro...@tr...> - 2013-06-20 21:48:05
|
On 06/19/13 15:26, Kevin Stone wrote: > I am trying to develop a python webapp using pysybase that is pretty > basic. I want to be able to create SQL QC reports that our users can > update on demand as they edit the database. > > However, I am having problems getting this to work in a multi-threaded > environment like cherrypy. If I execute one long query, no new > connections can be made, in fact all other threads come to a halt > until that one query returns. Is this something that is not supported > by this driver? > > Here is a sample test that I've been using: > > def sy_query(query): > db = Sybase.connect(dbServer,dbUser,dbPass,dbName) > cur = db.cursor() > cur.execute(query) > t1 = Thread(target=sy_query,args=("select * from blah",)) > t2 = Thread(target=sy_query,args=("select something from blah2",)) > t1.start() > t2.start() > t1.join() > t2.join() > > > As soon as thread 1 calls "status = ct_results(self->cmd, &result);" > inside of cmd.c nothing happens in either the main function nor in > thread 2. > Immediately after that line finishes, everything moves along. > > Any suggestions? I can't have a webapp that only works for one user at > a time. > > -Kevin It is the intent that everything done in C calls to Sybase would release the GIL and can run in different threads concurrently. However, this code hasn't had a lot of maintenance recently, and so may suffer from being out of sync with modern python versions. So if you're queries take a long time (like a minute) then we'd need to determine what your specific configuration is. What version of Sybase are you linked to, what platform are you on, and what version of python are you running? Thanks, Robert Boehne |