Things to help debug your issue.
. sockets can block, flush them
. threads can deadlock, if using “global” objects, specify “global” keyword within the thread, use mutex, queues or pubsub
. dlg.Destroy() does not directly close dlg. That call just puts an event in the queue to destroy it. Therefore you are not guaranteed the order of closing the threads, sockets or the system modal dialog.
Python Thread Deadlock Avoidance
Unable to destroy wx.Dialog in wxpython
On thing to try is to subclass wx.App and make your threads as attributes of that subclass. When the last wx.Frame is closed, YourWXAppSubClass exits MainLoop() and the Python Garbage Collector destroys all objects within the YourWXAppSubClass instance. If this still causes your app to hang on exit it’s likely your threads and sockets are not properly handling themselves (deadlocking or blocking).
To help isolate the root cause is to rip out all the gui code and pump dummy data into your sockets and see if the threads and sockets shutdown and exit the app as expected.
Not seeing the code, we are presuming that wxPython is the main “thread”.
···
On Sat, May 9, 2015 at 8:12 AM, sandyethadka sandyethadka@gmail.com wrote:
The app hangs(freezes) on closing. I have used some 4 sockets in my app. I
tried making them global to let me close them on closing the app. Still the
error persists.
def OnClose(self,event):
dlg = wx.MessageDialog(self, "Do you really want to close this
application?",“Confirm Exit”, wx.YES|wx.NO|wx.ICON_QUESTION)
result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_YES: #self.Close() #self.thread.join(2.0) #if sock: # sock.close() #if voicereceiversock: # voicereceiversock.close() if activesock: activesock.close() if sendsock: sendsock.close() self.Destroy() #self.Close() #self.ExitMainLoop()
Code.Eat.Sleep.Repeat
–
View this message in context: http://wxpython-users.1045709.n5.nabble.com/WxFrame-Closing-Issue-tp5724164.html
Sent from the wxPython-users mailing list archive at Nabble.com.
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.