process.pipe_limit
process.pipe_limit
Function
Set the unread buffer limit of the current Process object's stdout/stderr pipe. It is suitable for long-running sub-processes that continuously output progress. The caller can increase the upper limit based on business throughput. For example, the desktop batch processing task is set to 16MB.
Syntax
process(program).pipe_limit(bytes)
Parameters
| Parameters | Type | Required | Default value | Valid range | Description |
|---|---|---|---|---|---|
| bytes | Int | Yes | None | Greater than 0 and must be greater than or equal to BT_PROCESS_PIPE_READ_CHUNK | The number of unread bytes that a single stdout or stderr pipe is allowed to stage. |
Return value
| Type | Description |
|---|---|
| Process | Returns the new process builder. |
Example
cmd = process('docx_to_img.exe') .pipe_limit(16 * 1024 * 1024) .child() result = cmd.stdout().limit // Output: 16777216 print result
Notes
- pipe_limit(bytes) only affects the current Process object and does not modify global environment variables.
- When pipe_limit(bytes) is not called, BT_PROCESS_PIPE_LIMIT is read by default; when the environment variable is not configured, the default is 1048576 bytes.
- BT_PROCESS_PIPE_LIMIT and pipe_limit(bytes) limit the unread buffer "that has been read from the system pipe but has not been taken away by stdout_read/stderr_read", not the historical cumulative output during the process life cycle.
- If the unread buffer exceeds the upper limit, stdout_read/stderr_read will return a runtime error; the background reading thread will continue to drain the system pipe to prevent the child process from getting stuck because the pipe is full.