Exemplo n.º 1
0
def worker_thread(context):
    """The worker thread routines."""
    parameters = context.worker_parameters
    task_limit = parameters.task_limit

    if parameters.initializer is not None:
        if not run_initializer(parameters.initializer, parameters.initargs):
            return

    for task in get_next_task(context, task_limit):
        execute_next_task(task)
        context.task_queue.task_done()
Exemplo n.º 2
0
def worker_process(params, channel):
    """The worker process routines."""
    signal(SIGINT, SIG_IGN)

    if params.initializer is not None:
        if not run_initializer(params.initializer, params.initargs):
            os._exit(1)

    try:
        for task in worker_get_next_task(channel, params.task_limit):
            results = execute_next_task(task.payload)
            send_results(channel, Results(task.id, results))
    except (EOFError, EnvironmentError) as error:
        os._exit(error.errno)