[PyKDE] pyqt/mysqld thread deadlock
Phil Thompson
phil at river-bank.demon.co.uk
Wed Jan 1 21:18:01 GMT 2003
On Wednesday 01 January 2003 7:55 pm, Kaleb Pederson wrote:
> On Wednesday 01 January 2003 11:40 am, you wrote:
> > On Wednesday 01 January 2003 5:58 pm, Kaleb Pederson wrote:
> > > -----BEGIN PGP SIGNED MESSAGE-----
> > > Hash: SHA1
>
> <snip>
>
> > > It turns out, however, that the thread locks in the middle of my run()
> > > call and never completes. I'm cross-posting this message as I'm not
> > > familiar with Python extension modules and I don't know if PyQt could
> > > have caused this, it is a Python bug (or feature) or if there is a
> > > problem in the mysqldb module code.
>
> <snip>
>
> > > So does anyone have any idea what's wrong or how to fix it? Please
> > > email me as well if you aren't posting to the PyQt/Python list (kibab
> > > at icehouse dot net).
> >
> > To quote the Python source the lock is "to prevent parallel imports of
> > the same module in different threads to return with a partially loaded
> > module". What other imports (or the same import in other threads) might
> > be happening at the same time?
>
> At this point in my application there is nothing else "NEW" going on. That
> is, I'm in the middle of the event loop and this occurs in response to a
> button press. The thread, of course, returns control to my application
> which then waits for more user input. I can think of no reason anything
> else would be trying to import ListType, TupleType, or exc_info.
> Furthermore, this is the first thread I spawn (although the behavior is
> similar for all subsequent threads) thus, I would hope there would be no
> other blocked threads.
It would be any import, not just those specific things.
> Phil, wouldn't the block cease once the "other" thread had successfully
> imported the module thereby unblocking my thread? Never through the rest
> of my application life does that thread unblock.
Should do - but something obviously isn't right. If there was no other import
going on then the first call to PyThread_acquire_lock() in lock_import() in
import.c would succeed. It's not so it's blocking in the second call.
You could try instrumenting lock_import(), or replace the mysqldb calls with
code that still does the imports but nothing else.
Phil
Phil
More information about the PyQt
mailing list