while True:
    data += self.request.recv()
if not data:
    break
buffer += data
while True:
    if length is None:
        if ':' not in buffer:
            break
Python socket receive - incoming packets always have a different size