def _thread_run_user_function(user_function, result_queue, work_items, args,
    **kwargs):
    """ This is run by each thread. The work is processed and results are put into a queue. """
    for item in work_items:
        result = user_function(item, *args, **kwargs)
        result_queue.put(result)
        del item
