You can make your XML-RPC server accept multiple calls simultaneously. This means that multiple function calls can return a single result. In addition to this, if your server is multithreaded, then you can execute more code after the server is launched in a single thread. The program's main thread will not be blocked in this manner.
We can create a ServerThread
class inheriting from the threading.Thread
class and wrap a SimpleXMLRPCServer
instance in an attribute of this class. This can be set up to accept multiple calls.
Then, we can create two functions: one launches the multithreaded, multicall XML-RPC server and the other creates a client to that server.
Listing 8.2 gives the code for writing a multithreaded, multicall XML-RPC server, as shown:
#!/usr/bin/env python # Python Network Programming Cookbook -- Chapter – 8 # This program is optimized for Python 2.7. # It may run on any other version with/without modifications. import...