bgwrite - Start a background writing process

            @param fileObj <stream> - A stream backed by an fd

            @param data    <str/bytes/list> - The data to write. If a list is given, each successive element will be written to the fileObj and flushed. If a string/bytes is provided, it will be chunked according to the #BackgroundIOPriority chosen. If you would like a different chunking than the chosen ioPrio provides, use #bgwrite_chunk function instead.

               Chunking makes the data available quicker on the other side, reduces iowait on this side, and thus increases interactivity (at penalty of throughput).

            @param closeWhenFinished <bool> - If True, the given fileObj will be closed after all the data has been written. Default False.

            @param chainAfter  <None/BackgroundWriteProcess> - If a BackgroundWriteProcess object is provided (the return of bgwrite* functions), this data will be held for writing until the data associated with the provided object has completed writing.
            Use this to queue several background writes, but retain order within the resulting stream.


            @return - BackgroundWriteProcess - An object representing the state of this operation. @see BackgroundWriteProcess

def bgwrite(fileObj, data, closeWhenFinished=False, chainAfter=None, ioPrio=4):
    '''
        bgwrite - Start a background writing process

            @param fileObj <stream> - A stream backed by an fd

            @param data    <str/bytes/list> - The data to write. If a list is given, each successive element will be written to the fileObj and flushed. If a string/bytes is provided, it will be chunked according to the #BackgroundIOPriority chosen. If you would like a different chunking than the chosen ioPrio provides, use #bgwrite_chunk function instead.

               Chunking makes the data available quicker on the other side, reduces iowait on this side, and thus increases interactivity (at penalty of throughput).

            @param closeWhenFinished <bool> - If True, the given fileObj will be closed after all the data has been written. Default False.

            @param chainAfter  <None/BackgroundWriteProcess> - If a BackgroundWriteProcess object is provided (the return of bgwrite* functions), this data will be held for writing until the data associated with the provided object has completed writing.
            Use this to queue several background writes, but retain order within the resulting stream.


            @return - BackgroundWriteProcess - An object representing the state of this operation. @see BackgroundWriteProcess
    '''
        
    thread = BackgroundWriteProcess(fileObj, data, closeWhenFinished, chainAfter, ioPrio)
    thread.start()

    return thread