class_docstr: A print()-providing object that can override the stream output on
  a per-thread basis.
class_docstr_tok: ["A","print","(",")","-providing","object","that","can","override","the","stream","output","on","a","per-thread","basis","."]
docstr: Temporarily buffer this thread's stream and write out its contents
  at the end of the context manager.  Useful to avoid interleaved
  output when multiple threads output progress information.
docstr_tok: ["Temporarily","buffer","this","thread","'s","stream","and","write","out","its","contents","at","the","end","of","the","context","manager",".","Useful","to","avoid","interleaved","output","when","multiple","threads","output","progress","information","."]
code: def cork(self):
      """
      Temporarily buffer this thread's stream and write out its contents
      at the end of the context manager.  Useful to avoid interleaved
      output when multiple threads output progress information.
      """
      outer_stdout = self._get_stdout()
      assert not self._tls.corked, "reentrant call"
      inner_stdout = self._tls.stdout = io.StringIO()
      self._tls.corked = True
      try:
          yield
      finally:
          self._tls.stdout = outer_stdout
          self._tls.corked = False
          outer_stdout.write(inner_stdout.getvalue())
          outer_stdout.flush()
  
imports: import contextlib
  import io
  import random
  import socket
  import subprocess
  import sys
  import threading
  import uuid
  import numpy
label_desc: Use image node_id 5 for calling the _Printer obj's underlying member method code with example usage: obj.cork() without return types