Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting erratic "Invalid Signal signature" errors in PySide QWebPage
    primarykey
    data
    text
    <p>I am creating an application which automates loading webpages and creating screenshots (no, I cannot use one of the existing solutions) using PySide. One part of the app gets a list of URLs and loads each URL in turn using a <strong>new</strong> QWebPage object. After the page is loaded a screenshot is taken and the QWebPage object is deleted. </p> <p>Every now and then, given enough runs, I get the following error from PySide, as a RuntimeError exception:</p> <pre><code>Invalid Signal signature: loadStarted() Failed to connect signal loadStarted(). </code></pre> <p>The first line is printed to STDERR (probably by Qt?) and the second line is the Python exception. </p> <p>loadStarted() is a built-in QWebPage signal, not something I created. This works 90% of the time, and I could not figure out what makes it fail occasionally. </p> <p>To be honest, this app is quite unusual in design, as it hooks PySide/Qt into a uWSGI served web app - this means that for example I am not using the QApplication event loop but rather a local event loop for each page load. I am also not experienced in either Qt or Python so it's possible I'm making a lot of mistakes, but I can't figure out what those are. </p> <p>I am thinking <a href="https://stackoverflow.com/questions/7577290/pyside-signal-duplicating-behavior">this</a> post might have something to do with it, but I'm not sure. </p> <p>Any suggestions on where to look next? </p> <p><strong>UPDATE:</strong> the signal is connected through the following code: </p> <pre><code>class MyWebPage(QWebPage): def __init__(self, parent=None): super(MyWebPage, self).__init__(parent) self.loadStarted.connect(self.started) self.loadFinished[bool].connect(self.finished) </code></pre> <p>MyWebPage objects are created as children of a different single QObject instance which is not deleted until the process shuts down. They are deleted by calling page.deleteLater() once I am done with them. Since I am running a local event loop, I trigger deferred deletions to happen after exiting local event loop by calling:</p> <pre><code> # self.eventLoop is the local event loop, which at this stage is not running self.eventLoop.processEvents() # self.app is the QApplication instance self.app.sendPostedEvents(None, QEvent.DeferredDelete) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload