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

Phil Thompson phil at river-bank.demon.co.uk
Sat Feb 22 13:41:00 GMT 2003


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




More information about the PyQt mailing list