WAMP and wxPython

#1

Hi,

I tried to combine wxPython and a simple Autobahn WAMP component (see code pasted below). It creates the window and connects successfully, but when I close the window, it throws a StopIteration exception.

How can I close this gracefully?

I don’t get this exception when running the wxPython websocket example at https://github.com/crossbario/autobahn-python/blob/master/examples/twisted/websocket/wxpython/client.py .

I am on Windows and the versions are Autobahn Python 0.10.9, Twisted 15.4.0 and Crossbar 0.11.1.

Thanks

Florian

PS > python .\wxwamp.py

Joined.

Unhandled Error

Traceback (most recent call last):

File “.\wxwamp.py”, line 29, in

runner.run(MyComponent)

File “c:\something\libs\autobahn\py\autobahn\twisted\wamp.py”, line 256, in run

reactor.run()

— —

File “C:\pyenvs\something\lib\site-packages\twisted\internet\wxreactor.py”, line 169, in run

f()

exceptions.StopIteration:

import wx

class MyWindow(wx.Frame):

def __init__(self, *args, **kwds):

	wx.Frame.__init__(self, *args, **kwds)

from twisted.internet import wxreactor

wxreactor.install()

app = wx.App(redirect=False)

frame = MyWindow(None, -1, ‘Title’)

from twisted.internet import reactor

reactor.registerWxApp(app)

from twisted.internet.defer import inlineCallbacks

from autobahn.twisted.wamp import ApplicationSession, ApplicationRunner

class MyComponent(ApplicationSession):

@inlineCallbacks

def onJoin(self, details):

	print("Joined.")

	def add2(x, y):

		return x + y

	yield self.register(add2, u'com.myapp.add2')

runner = ApplicationRunner(u"ws://127.0.0.1:8080/ws", u"realm1", debug_wamp=False, debug=False)

frame.Show()

runner.run(MyComponent)

0 Likes