process.pipe_limit

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

Parameters

ParametersTypeRequiredDefault valueValid rangeDescription
bytesIntYesNoneGreater than 0 and must be greater than or equal to BT_PROCESS_PIPE_READ_CHUNKThe number of unread bytes that a single stdout or stderr pipe is allowed to stage.

Return value

TypeDescription
ProcessReturns the new process builder.

Example

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.