pys60 thread not working in symbian python

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?

Answers


Use the threading module. Threads 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.


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.


Need Your Help

Rails 4 devise user is able to sign up but not signin in ,

ruby-on-rails ruby devise

I'm building an rails app (I'm using rails 4) and using Devise for authentication, the problem is that I'm able to sign up and after sign up the user is automatically signed in , but if I log out ,...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.