Reputation: 19184
I am developing a sms app for symbian using pys60.
I have created a thread for sending the sms but theread is not working.
I want this thread to run in background, irrespective of applicaton closed or not.
contact index is a dictionary with contact nos and names.
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")
it enters "entered to send sms thread" but doesnt go after that.
the function sens_sms_thread is :
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)
can anyone tell me why it is not entering into this thread which will run in background inrrespective of application closed or not?
Upvotes: 0
Views: 582
Reputation: 1
Try the next snippet:
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
is the function running in background.
Upvotes: 0
Reputation: 118590
Use the threading
module. Thread
s created by this module will be waited on by the main thread before the process exits.
thread = threading.Thread(target=send_sms_thread, args=(contact_index,))
thread.start()
Threads created elsewhere, or with the daemon
attribute are not waited for.
Upvotes: 0