python - wxReactor Problem -


i developing program uses twisted , wxreactor. everytime try exit application, hangs, , have force quit it. wxpython onclose() event call reactor.stop(), knowledge should fix issue. in quest answer, i've come across ticket: www.twistedmatrix.com/trac/ticket/3948.
i've tried patch listed on page, no luck. i've been @ problem 2 weeks now, , pretty desperate :).

to give background on project: freeware client uses sockets connect multiplayer game server (currently plays monopoly , uno). if run it, notice there no graphics. because client provides audio feedback through speech synthesis , sound effects. target audience of project visually impaired gamers.

to test issue, run python rsg.py (which can found in src folder. in case need know, use python 2.6.5). in terminal, see output program produces (which server sends our client). once see line "connection made" (which should print shortly after running), try closing program (by clicking x). client hang few seconds, , need force quit application (on ubuntu, comes asking if want force quit application).

i have idea of why doesn't exit properly. when ran through gdb, 2 threads weren't exiting. strange enough, if server closed connection, exited program, work fine.

i appreciate help. thank in advance.

edit since asked provide basic demo of problem, here is:

import wx import sys twisted.internet import wxreactor wxreactor.install()  # import t.i.reactor after installing wxreactor: twisted.internet import reactor twisted.protocols.basic import linereceiver twisted.internet.protocol import clientfactory class zgpclient(linereceiver):     """our client object."""     def linereceived(self, datavar):          "as data received"          print datavar  class echofactory(clientfactory):     protocol =  zgpclient     def startedconnecting(self, connector):         global conn         conn = connector         print 'started connect.'      def senddata(self, data=""):       conn.transport.write(data.encode("ascii", "ignore") + "\n")  class main_window(wx.frame):  def __init__(self, parent, id, title):   super(main_window, self).__init__(parent, id, title, style=wx.default_frame_style)   self.bind(wx.evt_close, self.onclose)   self.show(true)   def onclose(self, event):    reactor.stop()    sys.exit()  if __name__ == "__main__":   app = wx.app()   frame = main_window(none, wx.id_any, "rs games client - no game")   reactor.registerwxapp(app)   sockobj = echofactory()   reactor.connecttcp("rsgamesmonserver.webhop.org", 3555, sockobj)   reactor.run()   app.mainloop() 

this work you:

def onclose(self, evt):     # ugly hack until wxreactor patched:     reactor._stopping = true     reactor.callfromthread(_threadedselect.threadedselectreactor.stop, reactor) 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -