-
-
Save colesbury/c48f50e95d5d68e24814a56e2664e587 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import redirect_stdout | |
from io import StringIO | |
from threading import Thread | |
import time | |
class Foo: | |
def __repr__(self): | |
time.sleep(0.2) | |
return "Foo" | |
def thread1(): | |
text = StringIO() | |
with redirect_stdout(text): | |
time.sleep(0.2) | |
def main(): | |
t1 = Thread(target=thread1, args=()) | |
t1.start() | |
time.sleep(0.1) | |
print(Foo()) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment