triqs.utility.redirect.T

class triqs.utility.redirect.T[source]

Bases: Thread

Background thread that pumps the C++ stdout into Python’s.

On run() the thread creates a pipe, redirects file descriptor 1 to its write end, and loops on a non-blocking read from the read end, forwarding any bytes to sys.stdout. The previous file descriptor 1 (captured in oldhandle at construction) is restored when stop() is invoked and the loop exits.

Attributes

go_on

(bool) Loop condition for run(); set to False by stop() to request thread termination.

oldhandle

(int) Saved duplicate of the original file descriptor 1, restored via os.dup2() when the thread stops.

Methods

run()

Run the pipe-pumping loop until stop() is called.

stop()

Request termination; the run loop exits at the next iteration.