def start(self): init_stdout_redirect() init_stderr_redirect() self._thread = threading.Thread(target=self._run, name='ptvsd.output.redirection') self._thread.daemon = True self._thread.start()
def _start(self): import weakref weak_self = weakref.ref(self) # Avoid cyclic ref def on_stdout(msg): self = weak_self() if self is not None: self._send_output('stdout', msg) def on_stderr(msg): self = weak_self() if self is not None: self._send_output('stderr', msg) init_stdout_redirect(on_stdout) init_stderr_redirect(on_stderr) return NoSocket()