minrk / wurlitzer

Capture C-level stdout/stderr in Python
MIT License
194 stars 24 forks source link

pipes are not redirected back in 3.1.0 #88

Closed scturtle closed 5 months ago

scturtle commented 5 months ago
import wurlitzer
with open("log", "w") as f, wurlitzer.pipes(f):
        print("foo")
print("bar")

In 3.0.3, it will print bar. But in 3.1.0 it will print nothing and bar is also in log. Tested on MacOS and Linux.

scturtle commented 5 months ago
import os
import wurlitzer
cpid = os.fork()
if cpid == 0:
    with open("log", "w") as f, wurlitzer.pipes(f):
            print("foo")
else:
    os.waitpid(cpid, 0)
    print("bar")

For this code, 3.1.0 seems to be right. But 3.0.3 puts nothing in log file.

minrk commented 5 months ago

Thanks! Tested and fixed by #89

minrk commented 5 months ago

released 3.1.1 with the fix