human
Complete this python program:
def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
assistant
#Here is the Python code you requested.

    """Start up a socket server on the specified port, and listen for new
    configurations.
    These will be sent as a file suitable for processing by fileConfig().
    Returns a Thread object on which you can call start() to start the server,
    and which you can join() when appropriate. To stop the server, call
    stopListening().
    """
    if (not thread):
        raise NotImplementedError('listen()    needs    threading    to    work')
    class ConfigStreamHandler(StreamRequestHandler, ):
        '\n                                Handler    for    a    logging    configuration    request.\n                                \n                                It    expects    a    completely    new    logging    configuration    and    uses    fileConfig\n                                to    install    it.\n                                '
        def handle(self):
            '\n                                                Handle    a    request.\n                                                \n                                                Each    request    is    expected    to    be    a    4-byte    length,    packed    using\n                                                struct.pack(">L",    n),    followed    by    the    config    file.\n                                                Uses    fileConfig()    to    do    the    grunt    work.\n                                                '
            import tempfile
            try:
                conn = self.connection
                chunk = conn.recv(4)
                if (len(chunk) == 4):
                    slen = struct.unpack('>L', chunk)[0]
                    chunk = self.connection.recv(slen)
                    while (len(chunk) < slen):
                        chunk = (chunk + conn.recv((slen - len(chunk))))
                    try:
                        import json
                        d = json.loads(chunk)
                        dictConfig(d)
                    except:
                        file = cStringIO.StringIO(chunk)
                        try:
                            fileConfig(file)
                        except (KeyboardInterrupt, SystemExit):
                            raise
                        except:
                            traceback.print_exc()
                    if self.server.ready:
                       ...