def METHOD_NAME(
    buffer,
    notempty,
    send_bytes,
    writelock,
    close,
    reducers,
    ignore_epipe,
    onerror,
    queue_sem,
):
    util.debug("starting thread to feed data to pipe")
    nacquire = notempty.acquire
    nrelease = notempty.release
    nwait = notempty.wait
    bpopleft = buffer.popleft
    sentinel = _sentinel
    if sys.platform != "win32":
        wacquire = writelock.acquire
        wrelease = writelock.release
    else:
        wacquire = None
    while True:
        try:
            nacquire()
            try:
                if not buffer:
                    nwait()
            finally:
                nrelease()
            try:
                while True:
                    obj = bpopleft()
                    if obj is sentinel:
                        util.debug("feeder thread got sentinel -- exiting")
                        close()
                        return
                    # serialize the data before acquiring the lock
                    obj_ = dumps(obj, reducers=reducers)
                    if wacquire is None:
                        send_bytes(obj_)
                    else:
                        wacquire()
                        try:
                            send_bytes(obj_)
                        finally:
                            wrelease()
                    # Remove references early to avoid leaking memory
                    del obj, obj_
            except IndexError:
                pass
        except BaseException as e:
            if ignore_epipe and getattr(e, "errno", 0) == errno.EPIPE:
                return
            # Since this runs in a daemon thread the resources it uses
            # may be become unusable while the process is cleaning up.
            # We ignore errors which happen after the process has
            # started to cleanup.
            if util.is_exiting():
                util.info(f"error in queue thread: {e}")
                return
            else:
                queue_sem.release()
                onerror(e, obj)