'Listen for pickles over tcp'

def listen_pickle(self):

    while 1:
        try:
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            s.bind((self.ip, self.port))
            s.setblocking(1)
            s.listen(5)
            logger.info(('listening    over    tcp    for    pickles    on    %s' % self.port))
            (conn, address) = s.accept()
            logger.info(('connection    from    %s:%s' % (address[0], self.port)))
            chunk = []
            while 1:
                self.check_if_parent_is_alive()
                try:
                    length = Struct('!I').unpack(self.read_all(conn, 4))
                    body = self.read_all(conn, length[0])
                    for bunch in self.gen_unpickle(body):
                        for metric in bunch:
                            chunk.append(metric)
                            if (len(chunk) > settings.CHUNK_SIZE):
                                try:
                                    self.q.put(list(chunk), block=False)
                                    chunk[:] = []
                                except Full:
                                    logger.info('queue    is    full,    dropping    datapoints')
                                    chunk[:] = []
                except Exception as e:
                    logger.info(e)
                    logger.info('incoming    connection    dropped,    attempting    to    reconnect')
                    break
        except Exception as e:
            logger.info(("can't    connect    to    socket:    " + str(e)))
            break
