code: def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
      """
      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):
          """
          Handler for a logging configuration request.
  
          It expects a completely new logging configuration and uses fileConfig
          to install it.
          """
  
          def handle(self):
              """
              Handle a request.
  
              Each request is expected to be a 4-byte length, packed using
              struct.pack(">L", n), followed by the config file.
              Uses fileConfig() to do the grunt work.
              """
              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)
                          assert isinstance(d, dict)
                          dictConfig(d)
                      except:
                          # Apply new configuration.
  
                          file = cStringIO.StringIO(chunk)
                          try:
                              fileConfig(file)
                          except (KeyboardInterrupt, SystemExit):
                              raise
                          except:
                              traceback.print_exc()
                      if self.server.ready:
                          self.server.ready.set()
              except socket.error as e:
                  if e.errno != RESET_ERROR:
                      raise
  
      class ConfigSocketReceiver(ThreadingTCPServer):
          """
          A simple TCP socket-based logging config receiver.
          """
  
          allow_reuse_address = 1
  
          def __init__(
              self,
              host="localhost",
              port=DEFAULT_LOGGING_CONFIG_PORT,
              handler=None,
              ready=None,
          ):
              ThreadingTCPServer.__init__(self, (host, port), handler)
              logging._acquireLock()
              self.abort = 0
              logging._releaseLock()
              self.timeout = 1
              self.ready = ready
  
          def serve_until_stopped(self):
              import select
  
              abort = 0
              while not abort:
                  rd, wr, ex = select.select(
                      [self.socket.fileno()], [], [], self.timeout
                  )
                  if rd:
                      self.handle_request()
                  logging._acquireLock()
                  abort = self.abort
                  logging._releaseLock()
              self.socket.close()
  
      class Server(threading.Thread):
          def __init__(self, rcvr, hdlr, port):
              super(Server, self).__init__()
              self.rcvr = rcvr
              self.hdlr = hdlr
              self.port = port
              self.ready = threading.Event()
  
          def run(self):
              server = self.rcvr(
                  port=self.port, handler=self.hdlr, ready=self.ready
              )
              if self.port == 0:
                  self.port = server.server_address[1]
              self.ready.set()
              global _listener
              logging._acquireLock()
              _listener = server
              logging._releaseLock()
              server.serve_until_stopped()
  
      return Server(ConfigSocketReceiver, ConfigStreamHandler, port)
  
imports: import cStringIO
  import errno
  import io
  import logging
  import logging.handlers
  import os
  import re
  import socket
  import struct
  import sys
  import traceback
  import types
  from SocketServer import ThreadingTCPServer, StreamRequestHandler
label_desc: Use image node_id 10 for calling a global function with example usage: listen(port) and returns: Server