Using raw_input causes problems with PyQt page loading

306 views Asked by At

I'm using PyQt4 to enter credentials into a domain login page and pull data from several additional pages in the domain. Everything works exactly as expected when supplying login or search credentials from within the code. When I open up raw_input to allow the user to enter information, it causes hang-ups trying to download one of the web-pages. I can't provide information on the page itself because it is on a corporate network, but it doesn't make sense that simply using raw_input would cause problems with QWebpage loads.

The QNetworkManager throws 1 of the expected 3 or 4 .finished signals and the QWebpage frame never throws the .loadfinished signal so it just hangs.

(I've tried to flushing stdin as well as seek(0) which gives me a bad file descriptor error). Has anyone run into such a problem before?

1

There are 1 answers

2
textshell On BEST ANSWER

raw_input uses synchronous/blocking IO without giving Qt a chance to continue processing events in the background. Qt isn't really prepared for it's processing to be halted in this way. In theory it should just resume when raw_input is finished. But maybe in the meantime a timeout occurred or something like that. You really should use signal/event based input when using Qt.

If GUI interaction is ok you should try QInputDialog::getText because it looks like a blocking call from the outside but internally lets Qt to continue processing background jobs.