prevent the main loop spinning too fast

def on_idle(self, event):
        '''prevent the main loop spinning too fast'''
        state = self.state

        if state.close_window.acquire(False):
            self.state.app.ExitMainLoop()

        now = time.time()
        if now - self.last_layout_send > 1:
            self.last_layout_send = now
            state.event_queue.put(win_layout.get_wx_window_layout(self))

        # receive any display objects from the parent
        obj = None

        while not state.object_queue.empty():
            obj = state.object_queue.get()

            if isinstance(obj, win_layout.WinLayout):
                win_layout.set_wx_window_layout(self, obj)
                
            if isinstance(obj, SlipObject):
                self.add_object(obj)

            if isinstance(obj, SlipPosition):
                # move an object
                object = self.find_object(obj.key, obj.layer)
                if object is not None:
                    object.update_position(obj)
                    if getattr(object, 'follow', False):
                        self.follow(object)
                    if obj.label is not None:
                        object.label = obj.label
                    if obj.colour is not None:
                        object.colour = obj.colour
                    state.need_redraw = True

            if isinstance(obj, SlipDefaultPopup):
                state.default_popup = obj

            if isinstance(obj, SlipInformation):
                # see if its a existing one or a new one
                if obj.key in state.info:
#                    print('update %s' % str(obj.key))
                    state.info[obj.key].update(obj)
                else:
#                    print('add %s' % str(obj.key))
                    state.info[obj.key] = obj
                state.need_redraw = True

            if isinstance(obj, SlipCenter):
                # move center
                (lat,lon) = obj.latlon
                state.panel.re_center(state.width/2, state.height/2, lat, lon)
                state.need_redraw = True

            if isinstance(obj, SlipZoom):
                # change zoom
                state.panel.set_ground_width(obj.ground_width)
                state.need_redraw = True
                
            if isinstance(obj, SlipFollow):
                # enable/disable follow
                state.follow = obj.enable

            if isinstance(obj, SlipFollowObject):
                # enable/disable follow on an object
                for layer in state.layers:
                    if obj.key in state.layers[layer]:
                        if hasattr(state.layers[layer][obj.key], 'follow'):
                            state.layers[layer][obj.key].follow = obj.enable
                
            if isinstance(obj, SlipBrightness):
                # set map brightness
                state.brightness = obj.brightness
                state.need_redraw = True

            if isinstance(obj, SlipClearLayer):
                # remove all objects from a layer
                if obj.layer in state.layers:
                    state.layers.pop(obj.layer)
                state.need_redraw = True

            if isinstance(obj, SlipRemoveObject):
                # remove an object by key
                for layer in state.layers:
                    if obj.key in state.layers[layer]:
                        state.layers[layer].pop(obj.key)
                state.need_redraw = True

            if isinstance(obj, SlipHideObject):
                # hide an object by key
                for layer in state.layers:
                    if obj.key in state.layers[layer]:
                        state.layers[layer][obj.key].set_hidden(obj.hide)
                state.need_redraw = True

        if obj is None:
            time.sleep(0.05)