def _read_payload(socket, payload_size):
remaining = payload_size<EOL>while remaining > <NUM_LIT:0>:<EOL><INDENT>data = read(socket, remaining)<EOL>if data is None:<EOL><INDENT>continue<EOL><DEDENT>if len(data) == <NUM_LIT:0>:  <EOL><INDENT>break<EOL><DEDENT>remaining -= len(data)<EOL>yield data<EOL><DEDENT>
From the given socket, reads and yields payload of the given size. With sockets, we don't receive all data at
once. Therefore this method will yield each time we read some data from the socket until the payload_size has
reached or socket has no more data.

Parameters
----------
socket
    Socket to read from

payload_size : int
    Size of the payload to read. Exactly these many bytes are read from the socket before stopping the yield.

Yields
-------
int
    Type of the stream (1 => stdout, 2 => stderr)
str
    Data in the stream