(internal) Function which is executed by worker pool processes or threads.
    It waits for tasks (function, data, arguments) at the input queue "inqueue"
    evaluates the result and passes it to the output queue "outqueue". It 
    optionally evaluates the function on a remote host.

def _pool_worker(inqueue, outqueue, host=None):
    """
    (internal) Function which is executed by worker pool processes or threads.
    It waits for tasks (function, data, arguments) at the input queue "inqueue"
    evaluates the result and passes it to the output queue "outqueue". It 
    optionally evaluates the function on a remote host.
    """
    put = outqueue.put
    get = inqueue.get
    if hasattr(inqueue, '_writer'):
        inqueue._writer.close()
        outqueue._reader.close()
    if host:
        host_port = host.split(':')
        try:
            host_port = [host_port[0], int(host_port[1])]
        except IndexError:
            pass
        conn = rpyc.classic.connect(*host_port)
        conn.execute(getsource(imports)) # provide @imports on server

    while True:
        try:
            #gc.disable()
            task = get()
            #gc.enable()
        except (EOFError, IOError):
            break

        if task is None:
            put(None)
            break

        if task[1] is None:
            put(task)
            continue

        job, func, args, kwargs, (i, data) = task
        if host:
            func = func._inject(conn) if hasattr(func, '_inject') else\
                   _inject_func(func, conn)
        try:
            ok, result = (True, func(data, *args, **kwargs))
        except Exception, excp:
            ok, result = (False, excp)
            #gc.disable(), gc.enable()
        put((job, i, ok, result))