# Path: harpoon/dockerpty/io.py
# def set_blocking(fd, blocking=True):
# def select(read_streams, write_streams, timeout=0):
#     def __init__(self, fd):
#     def fileno(self):
#     def set_blocking(self, value):
#     def read(self, n=4096):
#     def write(self, data):
#     def do_write(self):
#     def needs_write(self):
#     def close(self):
#     def __repr__(self):
#     def __init__(self, stream):
#     def fileno(self):
#     def set_blocking(self, value):
#     def read(self, n=4096):
#     def write(self, data):
#     def needs_write(self):
#     def do_write(self):
#     def close(self):
#     def _next_packet_size(self, n=0):
#     def __repr__(self):
#     def __init__(self, from_stream, to_stream, wait_for_output=True, propagate_close=True):
#     def fileno(self):
#     def set_blocking(self, value):
#     def flush(self, n=4096):
#     def is_done(self):
#     def __repr__(self):
# class Stream(object):
# class Demuxer(object):
# class Pump(object):
#     ERRNO_RECOVERABLE = [errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK]
# 
# Path: harpoon/dockerpty/tty.py
# def size(fd):
#     def __init__(self, fd, raw=True):
#     def __enter__(self):
#     def __exit__(self, *_):
#     def israw(self):
#     def start(self):
#     def stop(self):
#     def __repr__(self):
# class Terminal(object):


import sys
import signal
from ssl import SSLError
from harpoon.dockerpty import io
from harpoon.dockerpty import tty
    example, you can attach to a running container from within a Python REPL
    and when the container exits, the user will be returned to the Python REPL
    without adverse effects.
    """

    def __init__(self, client, container, interactive=True, stdout=None, stderr=None, stdin=None):
        """
        Initialize the PTY using the docker.Client instance and container dict.
        """

        self.client = client
        self.container = container
        self.raw = None
        self.interactive = interactive
        self.stdout = stdout or sys.stdout
        self.stderr = stderr or sys.stderr
        self.stdin = stdin or sys.stdin

    def start(self, **kwargs):
        """
        Present the PTY of the container inside the current process.

        This will take over the current process' TTY until the container's PTY
        is closed.
        """

        pty_stdin, pty_stdout, pty_stderr = self.sockets()
        pumps = []

        if pty_stdin and self.interactive:

# Path: harpoon/dockerpty/io.py
# def set_blocking(fd, blocking=True):
# def select(read_streams, write_streams, timeout=0):
#     def __init__(self, fd):
#     def fileno(self):
#     def set_blocking(self, value):
#     def read(self, n=4096):
#     def write(self, data):
#     def do_write(self):
#     def needs_write(self):
#     def close(self):
#     def __repr__(self):
#     def __init__(self, stream):
#     def fileno(self):
#     def set_blocking(self, value):
#     def read(self, n=4096):
#     def write(self, data):
#     def needs_write(self):
#     def do_write(self):
#     def close(self):
#     def _next_packet_size(self, n=0):
#     def __repr__(self):
#     def __init__(self, from_stream, to_stream, wait_for_output=True, propagate_close=True):
#     def fileno(self):
#     def set_blocking(self, value):
#     def flush(self, n=4096):
#     def is_done(self):
#     def __repr__(self):
# class Stream(object):
# class Demuxer(object):
# class Pump(object):
#     ERRNO_RECOVERABLE = [errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK]
# 
# Path: harpoon/dockerpty/tty.py
# def size(fd):
#     def __init__(self, fd, raw=True):
#     def __enter__(self):
#     def __exit__(self, *_):
#     def israw(self):
#     def start(self):
#     def stop(self):
#     def __repr__(self):
# class Terminal(object):


# Path: harpoon/dockerpty/pty.py
import sys
import signal
from ssl import SSLError
from harpoon.dockerpty import io
from harpoon.dockerpty import tty

    example, you can attach to a running container from within a Python REPL
    and when the container exits, the user will be returned to the Python REPL
    without adverse effects.
    """

    def __init__(self, client, container, interactive=True, stdout=None, stderr=None, stdin=None):
        """
        Initialize the PTY using the docker.Client instance and container dict.
        """

        self.client = client
        self.container = container
        self.raw = None
        self.interactive = interactive
        self.stdout = stdout or sys.stdout
        self.stderr = stderr or sys.stderr
        self.stdin = stdin or sys.stdin

    def start(self, **kwargs):
        """
        Present the PTY of the container inside the current process.

        This will take over the current process' TTY until the container's PTY
        is closed.
        """

        pty_stdin, pty_stdout, pty_stderr = self.sockets()
        pumps = []

        if pty_stdin and self.interactive:

            pumps.append(io.Pump(io.Stream(self.stdin), pty_stdin, wait_for_output=False))