[PyKDE] QMutexLocker doesn't unlock the mutex if an exception is
raised
Phil Thompson
phil at riverbankcomputing.co.uk
Sat Sep 16 11:26:46 BST 2006
On Saturday 16 September 2006 9:07 am, Lukáš Lalinský wrote:
> Hi,
>
> the Qt4/PyQt4 manuals specifically talk about using QMutexLocker to
> simplify exception handling in functions. However, in PyQt the mutex
> doesn't get unlocked if an exception is raised in the function code. I was
> wondering whether this is a bug or a technical limitation? If the latter,
> then perhaps it could be mentioned in the PyQt manual?
It's a feature of the way Python exceptions work. The locals aren't garbage
collected (and so the mutex isn't unlocked) while the exception is being
handled. Doing something like...
try:
raise Exception
finally:
del locker
...fixes it, but I agree that that rather misses the point of QMutexLocker in
the first place.
Phil
More information about the PyQt
mailing list