سؤال

أنا لم أرمز أبدا في بيثون من قبل، لذلك عذر التعليمات البرمجية الخاصة بي. لدي هذا البرنامج النصي الذي سيتم تشغيله في محطة لكن لا يمكنني الحصول عليه لتشغيل جانب العميل. أقوم بتشغيل هذا في تطبيق التيتانيوم في Appcelerator. على أي حال، لقد تم استكشاف الأخطاء وإصلاحها، ويبدو أنه لا يعمل المواضيع على الإطلاق. هل هذا قيود؟ هل يعلم أحد؟

<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>
هل كانت مفيدة؟

المحلول

الجواب، حاليا (يوم الجمعة، 19 يونيو، 2009) هو نعم، يمكن تشغيل الخيوط، ولكن لا شيء سوى الخيط الرئيسي يمكنه الوصول إلى كائنات جافا سكريبت، وهذا يشمل دوم. لذلك إذا كنت تخطط لتحديث واجهة المستخدم باستخدام تطبيق خيوط، فهذا غير ممكن ... حتى الآن. حتى يقوم فريق Appcelerator بإنشاء نوع من قائمة الانتظار إلى الخيط الرئيسي، ممكن عبر نظام ملزم.

يرجى الاطلاع على المناقشة في منتديات فيلد.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top