[PyKDE] Qt shutting down the process/Python interpreter - necessary?

Michael Lauer mickey at tm.informatik.uni-frankfurt.de
Fri Nov 8 12:29:00 GMT 2002


Hi,

in Qt there are certain places, where exit() is called, for instance,
if you construct a QPaintDevice before a QApplication, the process ends.

This behaviour - while perhaps being reasonable in a compiled language -
seems truly inappropriate in the context of an interpretated interactive
and dynamic environment such as the Python interpreter.

It would be much more useful if this would raise an exception, like,
PyQtException, which we could catch and react appropriate - for
instance, generating the application object and trying again.

It's especially bugging me in Qt/Embedded, where the offending exit()
call is triggered, when you create a QApplication in client mode but
no QWS server is running. It would be sufficient to just recreate the
QApplication with the appropriate parameter (-qws), but I can't because
my interpreter is being shutdown [see below] :(

========================================================

mickey at gandalf:~/work/elan$ python
Python 2.2.2 (#1, Oct 27 2002, 17:30:06) 
[GCC 3.2 (Mandrake Linux 9.0 3.2-1mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import qtpe
>>> try:                           
...  a=qtpe.QApplication([])
... except:
...  pass
... 
QSocket::writeBlock: Socket is not open
QSocket::writeBlock: Socket is not open
QSocket::writeBlock: Socket is not open
No Qt/Embedded server appears to be running.
If you want to run this program as a server,
add the "-qws" command-line option.
mickey at gandalf:~/work/elan$ 

========================================================

This behaviour is due to the following code:

========================================================

void QWSDisplayData::waitForConnection()
{
#ifndef QT_NO_QWS_MULTIPROCESS
    for ( int i = 0; i < 5; i++ ) {
	if ( csocket ) {
	    csocket->flush();
	    csocket->waitForMore(2000);
	}
	fillQueue();
	if ( connected_event )
	    return;
	usleep( 50000 );
    }
#else
    if ( connected_event )
	return;
#endif
    qWarning("No Qt/Embedded server appears to be running.");
    qWarning("If you want to run this program as a server,");
    qWarning("add the \"-qws\" command-line option.");
    exit(1);
}

========================================================

Now, my question... is there something I can do at python level
or is there something we can do at PyQt level to change this behaviour?

Yours,

-- 
:M:
--------------------------------------------------------------------------
Dipl.-Inf. Michael 'Mickey' Lauer  
mickey at tm.informatik.uni-frankfurt.de 
  Raum 10b - ++49 69 798 28358       Fachbereich Informatik und Biologie
--------------------------------------------------------------------------




More information about the PyQt mailing list