필자는 전에 Python으로 프로그래밍 한 적이 없으므로 코드를 사용 해보십시오. 터미널에서 실행할이 스크립트가 있지만 클라이언트 쪽을 실행하도록 가져올 수 없습니다. 나는 Appcelerator의 Titanium 응용 프로그램에서 이것을 실행하고 있습니다. 어쨌든, 나는 그것의 문제를 해결하고 그것은 전혀 스레드를 실행하지 않는 것 같습니다. 이것이 한계입니까? 아는 사람 있나요?클라이언트 측 파이썬은 스레드를 사용할 수 있습니까?
<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>