Changeset 18594 for lang/python

Show
Ignore:
Timestamp:
09/01/08 23:57:49 (4 months ago)
Author:
showyou
Message:

crochet マルチスレッド化。ただし排他処理がまだなのでよくセグフォ

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/python/crochet/chat_allsrc.py

    r17940 r18594  
    1313import Image 
    1414 
    15 import threading 
    16  
     15import thread 
    1716""" 
    1817画像取得用スレッド 
    1918""" 
    20 class ImageGetThread(threading.Thread): 
     19class ImageGetFrame(wx.Frame): 
    2120        def __init__(self,url,callbackFunc,result): 
    22                 threading.Thread.__init__(self) 
    2321                self.url = url  
    2422                self.func = callbackFunc  
    2523                self.result = result 
     24        def start(self): 
     25                thread.start_new_thread(self.run(), ()) 
     26 
    2627        def run(self): 
    2728                import urllib,time 
     
    3031                #time.sleep(1) 
    3132                self.func(imagePath,self.result) 
     33                 
     34 
    3235""" 
    3336twitterにhttpRequestを投げるスレッド 
    3437""" 
    35 class TwDMHttpThread(threading.Thread): 
     38class TwDMHttpFrame(wx.Frame): 
    3639        def __init__(self,tw,func): 
    37                 threading.Thread.__init__(self) 
    3840                self.tw = tw 
    3941                self.func = func 
     42        def start(self): 
     43                thread.start_new_thread(self.run, ()) 
    4044        def run(self): 
    4145                #ここに通信処理を書く 
     
    4549twitterにhttpRequestを投げるスレッド 
    4650""" 
    47 class TwReplyHttpThread(threading.Thread): 
     51class TwReplyHttpFrame(wx.Frame): 
    4852        def __init__(self,tw,func): 
    49                 threading.Thread.__init__(self) 
    5053                self.tw = tw 
    5154                self.func = func 
     55        def start(self): 
     56 
     57                thread.start_new_thread(self.run, ()) 
     58         
    5259        def run(self): 
    5360                #ここに通信処理を書く 
     
    5764twitterにhttpRequestを投げるスレッド 
    5865""" 
    59 class TwHttpThread(threading.Thread): 
     66class TwHttpFrame(wx.Frame): 
    6067        def __init__(self,tw,func): 
    61                 threading.Thread.__init__(self) 
    6268                self.tw = tw 
    6369                self.func = func 
     70        def start(self): 
     71                thread.start_new_thread(self.run, ()) 
     72 
    6473        def run(self): 
    6574                #ここに通信処理を書く 
     
    8998         
    9099        def Reflesh(self): 
    91                 t = TwDMHttpThread(self.owner.tw,self.RefleshList) 
    92                 t.run() 
     100                t = TwDMHttpFrame(self.owner.tw,self.RefleshList) 
     101                t.start() 
    93102""" 
    94103最近のfriendsの発言一覧を表示するページ 
     
    193202 
    194203        def Reflesh(self): 
    195                 t = TwHttpThread(self.owner.tw,self.RefleshList) 
    196                 t.run() 
     204                t = TwHttpFrame(self.owner.tw,self.RefleshList) 
     205                t.start() 
    197206         
    198207        def RefleshList(self,a): 
     
    262271         
    263272        def Reflesh(self): 
    264                 t = TwReplyHttpThread(self.owner.tw,self.RefleshList) 
    265                 t.run() 
     273                t = TwReplyHttpFrame(self.owner.tw,self.RefleshList) 
     274                t.start() 
    266275 
    267276         
     
    308317                 
    309318        def __init__(self, parent=None): 
     319                #from pit import Pit 
     320                #twUserdata = Pit.get('twitter.com',{'require' : {'user':'','pass':''}}) 
    310321                twUserdata = self.loadUserData(".chat/twdata") 
    311322                wx.Frame.__init__(self,None, -1, "crochet") 
     
    391402         
    392403        def OnUpdate(self, event): 
     404                self.SetStatusBar(u"新着取得中...") 
    393405                self.RefleshTw() 
    394                 self.SetNowTime2StatusBar() 
    395406         
    396407        def OnReplyUpdate(self, event): 
     408         
     409                self.SetStatusBar(u"Reply取得中") 
    397410                self.replyPage.Reflesh() 
    398                 #self.SetNowTime2StatusBar() 
    399411 
    400412        def OnDMUpdate(self, event): 
     413                 
     414                self.SetStatusBar(u"DM取得中...") 
    401415                self.directPage.Reflesh() 
    402                 #self.SetNowTime2StatusBar() 
    403  
     416 
     417        def SetStatusBar(self,str): 
     418                 
     419                sb = wx.GetApp().GetTopWindow().GetStatusBar() 
     420                sb.SetStatusText(str) 
    404421        def SetNowTime2StatusBar(self): 
    405422                #現在時刻を表示 
     
    458475                #print "urlName:"+urlName 
    459476                #thread化したいですね 
    460                 t = ImageGetThread(urlName,self.WebImageCallback,result) 
    461                 t.run() 
     477                t = ImageGetFrame(urlName,self.WebImageCallback,result) 
     478                t.start() 
    462479 
    463480        def WebImageCallback(self,imageData,result):