[PyKDE] PyQt - getting unexpected async reply in threaded app (newbie)

Nicholas John Murison nick at urgusabic.net
Sun Feb 23 17:19:00 GMT 2003


Ah, I think I've solved it now.

Locking the QApplication object would be a good idea!

As far as I can remember, somewhere in the PyQt it says there should be
a global qApp variable.  However, my code can't seem to find it, so I've
passed on the object through constructor parameters to the threads.

This seems to be working, and I hope it is the right way to go about
these kind of things.

Thanks,
Nick Murison

On Sat, 2003-02-22 at 12:40, Phil Thompson wrote:
> On Saturday 22 February 2003 11:53 am, Nicholas John Murison wrote:
> > Hi all,
> >
> > Both a colleague and I have run into the identical problem when using
> > PyQt in a threaded environment.
> >
> > I have a threaded app, which uses QThreads for the threading model.  I
> > am trying to get the child threads to be able to create and display
> > windows as part of the GUI.  To my knowledge, all GUI creation must take
> > place within one thread in PyQt.  Therefore I am trying to do all GUI
> > calls from the main thread.  This isn't working, and I keep getting
> > "unexpected async reply" errors from Xlib.
> >
> > Let me demonstrate my object instance hierarchy:
> >
> > __main__
> >   -> creates a QApplication
> >   -> creates a QObject derivative
> >      -> creates QThread derivatives
> >         -> creates SocketServer.TCPServer derivatives
> >            -> creates SocketServer.BaseRequestHandler derivatives
> > 	      -> calls main QObject derivative instance and asks for a
> >                  window to be displayed
> >
> > This last step is where it all goes wrong.
> >
> > My classes are split over several files, a few of which need to import
> > qt.  So the qt module is imported several times over, which hopefully is
> > ok.
> >
> > Also, I tried referring to the global qApp object, both in my
> > BaseRequestHandler derivative class, and in the main QObject derivative
> > class in the main thread.  In both of these cases, Python claimed qApp
> > did not exist.
> >
> > Any suggestions would be most helpful.
> 
> At the risk of stating the obvious, have you read the "Thread Support in Qt" 
> section of the Qt documentation?
> 
> Phil
> 
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.gmd.de
> http://mats.gmd.de/mailman/listinfo/pykde
-- 
Nicholas John Murison
~~~~~~~~~~~~~~~~~~~~~
http://www.urgusabic.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20030223/e1910de9/attachment.bin


More information about the PyQt mailing list