Details
Description
Hey,
I'm using WebView with a custom NetworkAccessManager via PyQt5 and porting an app from QT4 to QT5. A a custom NetworkAccessManager implements network request timeouts: after a timeout reply.abort() is called. It used to work fine in Qt4, but Qt5 in some cases goes into an infinite loop printing
QIODevice::read (QNetworkReplyHttpImpl): device not open
messages. It happens when a remote server accepts connection, sends initial Content-Type header, then sends some data (a few bytes), and then waits doing nothing.
If a server accepts connection, sends Content-Type header and then waits without sending the data, qt doesn't go into an infinite loop, but prints a single message:
QIODevice::read (QNetworkReplyHttpImpl): device not open
An example to reproduce this issue (in PyQT): https://gist.github.com/kmike/ff287998e02fa953b4a2.
Problematic resource implementation (in Twisted, I'm not sure if it is useful for you): https://github.com/scrapinghub/splash/blob/64014968fa6e9d5a88fd131b246ddfc875a50039/splash/tests/mockserver.py#L218
I've attached a file with an OS X sample of a process when it is in an infinite loop. It looks like reply.abort() triggers "fiished" signal, which in turn triggers MIME sniffing, and then sniffer tries to read from a closed reply, and for some reason 'finished' is fired again.
If all 'finished' handlers are disconnect from reply before calling reply.abort (this line is commented out in example), then there is no infinite loop, but one 'device not open' message is still printed. WebView is not working properly in this case, so it is not a workaround.