2009-06-14 9 views
0

私は決して前にPythonでプログラミングしたことがないので、私のコードを許してください。私はターミナルで実行されるこのスクリプトを持っていますが、私はクライアント側を実行することができません。私はAppceleratorのTitaniumアプリケーションでこれを実行しています。とにかく、私はそれをトラブルシューティングしており、それは全くスレッドを実行していないようです。これは限界ですか?誰か知っていますか?クライアントサイドのPythonはスレッドを使用できますか?

<script type="text/python"> 
import os 
import sys 
import Queue 
import threading 
class FindThread (threading.Thread): 
    def run (self): 
     running = True 
     while running: 
     if jobPool.empty(): 
      #print '<< CLOSING THREAD' 
      running = False 
      continue 

     job = jobPool.get() 
     window.document.getElementById('output').innerHTML += os.path.join(top, name) 
     if job != None: 
      dirSearch(job)    

jobPool = Queue.Queue (0) 

def findPython(): 
    #output = window.document.getElementById('output') 
    window.document.getElementById('output').innerHTML += "Starting" 
    dirSearch("/") 
    # Start 10 threads: 
    for x in xrange (10): 
     #print '>> OPENING THREAD' 
     FindThread().start() 

def dirSearch(top = "."): 
    import os, stat, types 
    names = os.listdir(top) 
    for name in names: 
     try: 
      st = os.lstat(os.path.join(top, name)) 
     except os.error: 
      continue 
     if stat.S_ISDIR(st.st_mode): 
      jobPool.put(os.path.join(top, name)) 
     else: 
      window.document.getElementById('output').innerHTML += os.path.join(top, name) 

window.findPython = findPython 

</script> 

答えて

2

答えは、はい、それはスレッドを実行することができますが、メインスレッドが、何もではJavaScriptオブジェクトにアクセスすることはできません現在(6月(金曜日)19、2009)、これはDOMが含まれています。だから、あなたがスレッド型のアプリケーションでUIを更新しようとしているのであれば、これは不可能です。 Appceleratorチームがバインディングシステムを介して可能なメインスレッドへの何らかの並べ替えを作成するまで。

​​のディスカッションを参照してください。

関連する問題