called in idle time

def idle_task(self):
        '''called in idle time'''
        
        try:
            datagram = self.port.recvfrom(self.BUFFER_SIZE)
            data = json.loads(datagram[0])
            
        except socket.error as e:
            if e.errno in [ errno.EAGAIN, errno.EWOULDBLOCK ]:
                return
            raise
        
        for key in data.keys():
            self.data[key] = data[key]
        
        try:
            self.master.mav.gps_input_send(
                self.data['time_usec'],
                self.data['gps_id'],
                self.data['ignore_flags'],
                self.data['time_week_ms'],
                self.data['time_week'],
                self.data['fix_type'],
                self.data['lat'],
                self.data['lon'],
                self.data['alt'],
                self.data['hdop'],
                self.data['vdop'],
                self.data['vn'],
                self.data['ve'],
                self.data['vd'],
                self.data['speed_accuracy'],
                self.data['horiz_accuracy'],
                self.data['vert_accuracy'],
                self.data['satellites_visible'])
        
        except Exception as e:
            print("GPS Input Failed:", e)