Package pybaz :: Package backends :: Module forkexec :: Class exec_safe_iter_stdout
[frames | no frames]

Type exec_safe_iter_stdout

object --+
         |
        exec_safe_iter_stdout


Iterator over the output of a child process.

Fork/exec a process with its output piped. Each iteration will cause a iteration of the process output pipe. The pipe is properly closed whenever the output is exhausted or the iterator is deleted.

If the output is exhausted, the process exit status is checked and an ExecError exception will be raised for abnormal or unexpected exit status.


Method Summary
  __init__(self, program, args, stdin, stderr, expected, delsignal, chdir, logger)
  __del__(self)
Destructor.
  __iter__(self)
Iterator.
  close(self)
Close the pipe and wait the child process.
  next(self)
Iteration method.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Property Summary
  finished
  status

Method Details

__del__(self)
(Destructor)

Destructor. If needed, close the pipe and wait the child process.

If child process has already been joined, it means the iterator was deleted before being exhausted. It is assumed the return status is not cared about.

__iter__(self)

Iterator. Return self.

close(self)

Close the pipe and wait the child process.

If the output is not exhausted yet, you should be prepared to handle the error condition caused by breaking the pipe.

next(self)

Iteration method. Iterate on the pipe file.

Close the pipe and wait the child process once output is exhausted.

Use file.readline instead of file.next because we want maximal responsiveness to incremental output. The pipe mechanism itself provides buffering.


Generated by Epydoc 2.1 on Fri Jul 7 17:05:32 2006 http://epydoc.sf.net