簡體   English   中英

pys60線程在Symbian Python中不起作用

[英]pys60 thread not working in symbian python

我正在使用pys60為symbian開發一個短信應用程序。 我創建了一個用於發送短信的線程,但是readread無法正常工作。
我希望此線程在后台運行,無論是否關閉了applicaton。
聯系人索引是一本包含聯系人編號和姓名的字典。

def send_sms(contact_index):
    import thread
    appuifw.note(u"entered to send sms thread")
    tid = thread.start_new_thread(send_sms_thread, (contact_index, ))
    appuifw.note(u"completed")

它進入“輸入發送短信線程”,但沒有去。
函數sens_sms_thread是:

def send_sms_thread(contact_index):
    appuifw.note(u"entering the thread in sending sms in loops")
    for numbers in contact_index:
        name = contact_index[number]
        appuifw.note(u"sending sms to %s ." % name)
        messaging.sms_send(numbers, message_content, '7bit', cb, '')
        e32.ao_sleep(30)

誰能告訴我為什么不進入該線程,而無論應用程序是否關閉,該線程都會在后台運行?

嘗試下一個代碼段:

if __name__=='__main__':

    th = e32.ao_callgate(Udp_recv)
    thread.start_new_thread(th,())

    for i in range(10):
        tmp = (str(i)+data)[0:10]

Udp_recv是在后台運行的函數。

使用threading模塊。 Thread此模塊創建旨意主線程的進程退出之前,一直在等待。

thread = threading.Thread(target=send_sms_thread, args=(contact_index,))
thread.start()

不會等待在其他位置創建的線程或具有daemon屬性的線程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM