Function: python-shell-accept-process-output

python-shell-accept-process-output is a byte-compiled function defined in python.el.gz.

Signature

(python-shell-accept-process-output PROCESS &optional TIMEOUT REGEXP)

Documentation

Accept PROCESS output with TIMEOUT until REGEXP is found.

Optional argument TIMEOUT is the timeout argument to accept-process-output calls. Optional argument REGEXP overrides the regexp to match the end of output, defaults to comint-prompt-regexp. Returns non-nil when output was properly captured.

This utility is useful in situations where the output may be received in chunks, since accept-process-output gives no guarantees they will be grabbed in a single call. An example use case for this would be the CPython shell start-up, where the banner and the initial prompt are received separately.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-shell-accept-process-output (process &optional timeout regexp)
  "Accept PROCESS output with TIMEOUT until REGEXP is found.
Optional argument TIMEOUT is the timeout argument to
`accept-process-output' calls.  Optional argument REGEXP
overrides the regexp to match the end of output, defaults to
`comint-prompt-regexp'.  Returns non-nil when output was
properly captured.

This utility is useful in situations where the output may be
received in chunks, since `accept-process-output' gives no
guarantees they will be grabbed in a single call.  An example use
case for this would be the CPython shell start-up, where the
banner and the initial prompt are received separately."
  (let ((regexp (or regexp comint-prompt-regexp)))
    (catch 'found
      (while t
        (when (not (accept-process-output process timeout))
          (throw 'found nil))
        (when (looking-back
               regexp (car (python-util-comint-last-prompt)))
          (throw 'found t))))))