I haven't been able to find any gpsd examples that do not do something similar to Python GPS Module: Reading latest GPS Data. Using multiprocessing I wrote a Process that handles reading gps data from a device with the following inside run(). NOTE, I want to be able to stop this process so I cannot use just the next() function of the gps session as it is a blocking call:
# connect to gpsd
g = gps.gps('127.0.0.1',2947)
g.stream(gps.WATCH_ENABLE)
while True:
try:
if poisonpillq.get_nowait() == '!STOP!': break
except Queue.Empty:
if g.waiting():
rpt = g.next()
if rpt['class'] == 'TPV':
--- store_gps_data from rpt/g ---
Doing this, my CPU hits 100%. Testing CPU usage with program xpgs, the CPU hits at max 15% usage. So how can this usage be circumvented?