I was testing threads in PYS60, this code works:
Code:
import e32
import thread,time
def process():
timer = e32.Ao_timer()
while 1:
print "Tread1"
timer.after(.4)
def process2():
timer = e32.Ao_timer()
while 1:
print "Tread2"
timer.after(.4)
timer2 = e32.Ao_timer()
thread.start_new_thread(process, ())
thread.start_new_thread(process2, ())
while 1:
print "Main"
timer2.after(.2)
Then i tested with urllib retriving data from server and it works
But if i try get location with thread i get: NaN always
I have this code for get location:
Code:
def gpsGetPosition():
lastPositionGPS = positioning.position(course=1,satellites=1)['position']
print lastPositionGPS['latitude'],lastPositionGPS['vertical_accuracy'],lastPositionGPS['longitude'],lastPositionGPS['horizontal_accuracy']
return
If i call the function with out thread i get rigth location !
But if i try call the function in thread:
Code:
thread.start_new_thread(gpsGetPosition, ())
The function returns inmediatly with "Nan Nan Nan Nan" results, it seems like the thread dont wait for the position.position() function inside the funticion gpsGetPosition.
Any help? ideas?
Thanks !!!