From what I understand about twisted, nothing running in the reactor thread should block. All blocking activities should be delegated to other threads, to fire callbacks back into the reactor thread when they're done.
So does this apply to gtk things as well? For example, I want to display a "connection failed" message if the connection... failed. Do I do:
def connectionFailed(self, reason):
dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
buttons=gtk.BUTTONS_CLOSE,
message_format="Could not connect to server:\n%s" % (
reason.getErrorMessage()))
dlg.run()
or:
def connectionFailed(self, reason):
dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
buttons=gtk.BUTTONS_CLOSE,
message_format="Could not connect to server:\n%s" % (
reason.getErrorMessage()))
reactor.callInThread(dlg.run)
or:
def connectionFailed(self, reason):
def bloogedy():
dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
buttons=gtk.BUTTONS_CLOSE,
message_format="Could not connect to server:\n%s" % (
reason.getErrorMessage()))
dlg.run()
reactor.callInThread(bloogedy)
?
EDIT: Ooh ok, the latter two really messed up. so I guess the answer is the first. Then my question is: why? It seems like this would block the reactor thread.