title: Multi-threaded XML-RPC (python3.7.1)
body: <p><em>Server:</em></p>
  
  <pre><code>  import time                                                                   
    import random                                                                 
    from threading import Thread                                                  
    from xmlrpc.server import SimpleXMLRPCServer                                  
  
    class ServerThread(Thread):                                                   
        def __init__(self, server_addr):                                          
        ┆   Thread.__init__(self)                                                 
        ┆   self.server = SimpleXMLRPCServer(server_addr)                         
        ┆   self.server.register_function(sleep, 'sleep')                         
  
        def run(self):                                                            
        ┆   self.server.serve_forever()                                           
  
    # sleep for random number of seconds                                          
    def sleep():                                                                  
        r = random.randint(2,10)                                                  
        print('sleeping {} seconds'.format(r))                                    
        time.sleep(r)                                                             
        return 'slept {} seconds, exiting'.format(r)                              
  
    # run server                                                                  
    def run_server(host="localhost", port=8000):                                  
        server_addr = (host, port)                                                
        thread1 = ServerThread(server_addr)                                       
        thread1.start()                                                           
        print("Server thread started. Testing server ...")                        
        print('listening on {} port {}'.format(host, port))                       
  
    if __name__ == '__main__':                                                    
       run_server()
  </code></pre>
  
  <p><em>Client:</em></p>
  
  <pre><code>import xmlrpc.client
  
  server = xmlrpc.client.ServerProxy("http://localhost:8000/", allow_none=True)
  
  print(server.sleep())
  print(server.sleep())
  print(server.sleep())
  print(server.sleep())
  </code></pre>
  
  <p>Question:</p>
  
  <p>I can't create multiple <em>ServerThread</em> instances all listening to the same port, throws exception. </p>
  
  <p>I would like to see all 4 threads executing in parallel.</p>
  
  <p>What am I missing? Does a lecture on GIL follow?</p>