parameters: (sock, exclusive)
docstring: Lisenting loop
docstring_summary: Lisenting loop
docstring_tokens: Lisenting loop
function: def _listen_loop(sock, exclusive):
      """Lisenting loop"""
      last_proc = None
      while True:
          conn, addr = sock.accept()
  
          if last_proc and last_proc.is_alive() and exclusive:
              logging.info("Kill last call")
              last_proc.terminate()
  
          logging.info("RPCServer: connection from %s", addr)
          magic = struct.unpack("@i", _recvall(conn, 4))[0]
          if magic != RPC_MAGIC:
              conn.close()
              continue
          keylen = struct.unpack("@i", _recvall(conn, 4))[0]
          key = py_str(_recvall(conn, keylen))
          if not key.startswith("client:"):
              conn.sendall(struct.pack("@i", RPC_MAGIC + 2))
          else:
              conn.sendall(struct.pack("@i", RPC_MAGIC))
          logging.info("Connection from %s", addr)
  
          process = multiprocessing.Process(target=_serve_loop, args=(conn, addr))
          process.deamon = True
          process.start()
          last_proc = process
          # close from our side.
          conn.close()
function_tokens: def _listen_loop ( sock , exclusive ) : last_proc = None while True : conn , addr = sock . accept ( ) if last_proc and last_proc . is_alive ( ) and exclusive : logging . info ( "Kill last call" ) last_proc . terminate ( ) logging . info ( "RPCServer: connection from %s" , addr ) magic = struct . unpack ( "@i" , _recvall ( conn , 4 ) ) [ 0 ] if magic != RPC_MAGIC : conn . close ( ) continue keylen = struct . unpack ( "@i" , _recvall ( conn , 4 ) ) [ 0 ] key = py_str ( _recvall ( conn , keylen ) ) if not key . startswith ( "client:" ) : conn . sendall ( struct . pack ( "@i" , RPC_MAGIC + 2 ) ) else : conn . sendall ( struct . pack ( "@i" , RPC_MAGIC ) ) logging . info ( "Connection from %s" , addr ) process = multiprocessing . Process ( target = _serve_loop , args = ( conn , addr ) ) process . deamon = True process . start ( ) last_proc = process # close from our side. conn . close ( )