<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _read_in_thread(address, pty, blocking):
 """Read data from the pty in a thread. """

    client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    client.connect(address)

    while 1:
        data = pty.read(4096, blocking=blocking)

        if not data and not pty.isalive():
            while not data and not pty.iseof():
                data += pty.read(4096, blocking=blocking)

            if not data:
                try:
                    client.send(b'')
                except socket.error:
                    pass
                break
        try:
            client.send(data)
        except socket.error:
            break

    client.close()