'Updates the uncollected logs list in a multi-process safe manner.
:param update_func - a function that updates the list of uncollected
logs. Should take one parameter, the list to be updated.'

def _update_uncollected_logs_list(self, update_func):

    if self._uncollected_log_file:
        log_file = open(self._uncollected_log_file, 'r+')
        fcntl.flock(log_file, fcntl.LOCK_EX)
    try:
        uncollected_logs = pickle.load(log_file)
        update_func(uncollected_logs)
        log_file.seek(0)
        log_file.truncate()
        pickle.dump(uncollected_logs, log_file)
        log_file.flush()
    finally:
        fcntl.flock(log_file, fcntl.LOCK_UN)
        log_file.close()
