'Does some amount of work on the next queued background update
Args:
desired_duration_ms(float): How long we want to spend
updating.
Returns:
A deferred that completes once some amount of work is done.
The deferred will have a value of None if there is currently
no more work to do.'

@defer.inlineCallbacks
def do_next_background_update(self, desired_duration_ms):

    if (not self._background_update_queue):
        updates = (yield self._simple_select_list('background_updates', keyvalues=None, retcols=('update_name', 'depends_on')))
        in_flight = set((update['update_name'] for update in updates))
        for update in updates:
            if (update['depends_on'] not in in_flight):
                self._background_update_queue.append(update['update_name'])
    if (not self._background_update_queue):
        defer.returnValue(None)
    update_name = self._background_update_queue.pop(0)
    self._background_update_queue.append(update_name)
    res = (yield self._do_background_update(update_name, desired_duration_ms))
    defer.returnValue(res)
