Python Forum
A single Thread Crashes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A single Thread Crashes
#5
I spent 2 days to try on Windows 7 / 10 and x64 / x32; cut the code to minimum and remove all calls to timer & sleep but still crash with stop message (Not Responding) "Python has stopped working. A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available." when not calling the thread, it seems ok. since the function code is kind of long. Let me know if need, I will post. I use python 3.6.2. Thanks.
import wx
import wx.grid
import pandas as pd
import googlefinance.client as gf
from threading import *

class RunThread(Thread):
    def __init__(self, event, win):
        Thread.__init__(self)
        self.stopped = event
        self.start()
    def run(self):
        print('Loading 0,0 ..')
        #win.Update_5M(0, 0)
        while True:
            print('Loading 1,12 ..')
            #win.Update_5M(1, 12)
            self.stopped.wait(20)
class Frame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, title="Thread Crash", size=(530, 742), pos = (500, 100))
        wx.Panel(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        self.grid = self.Create_Grid()
        stopFlag = Event()
        RunThread(stopFlag, self)
    def Update_5M(self, n, m):
        self.dfg, self.dfr = self.Load_Data_Frame(n)
        self.Update_Grid(self.dfr, self.grid, 'red', m)
        self.Update_Grid(self.dfg, self.grid, 'green', m)
    def Create_Grid(self):
        self.colno = 11
        self.colsz = [43,40,22,40,44,60,40,40,40,40,40]
        grid = wx.grid.Grid(self, size=(522, 700), pos=(0,0))
        grid.CreateGrid(1,11)
        grid.SetRowLabelSize(60)
        grid.SetLabelFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL))
        grid.SetDefaultCellAlignment(wx.ALIGN_RIGHT,wx.ALIGN_CENTRE)
        for col in range(self.colno):
            grid.SetColSize(col,self.colsz[col])
        return grid
if __name__ == "__main__":
    app = wx.App()
    win = Frame()
    win.Show()
    app.MainLoop()
Reply


Messages In This Thread
A single Thread Crashes - by ian - Aug-24-2017, 10:09 PM
RE: A single Thread Crashes - by Larz60+ - Aug-24-2017, 10:16 PM
RE: A single Thread Crashes - by snippsat - Aug-25-2017, 09:58 AM
RE: A single Thread Crashes - by Larz60+ - Aug-25-2017, 10:03 AM
RE: A single Thread Crashes - by ian - Aug-27-2017, 02:59 PM
RE: A single Thread Crashes - by Larz60+ - Aug-27-2017, 05:06 PM
RE: A single Thread Crashes - by ian - Aug-27-2017, 10:26 PM
RE: A single Thread Crashes - by ian - Aug-28-2017, 12:09 AM
RE: A single Thread Crashes - by Larz60+ - Aug-28-2017, 12:19 AM
RE: A single Thread Crashes - by ian - Aug-28-2017, 02:28 AM
RE: A single Thread Crashes - by Larz60+ - Aug-28-2017, 02:56 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020