I am working in an environment that creates a Pyramid web service on my localhost. From the setup of this server, I would like to be able to spawn a different thread with a different server that manages queues of requests to the main one, and this second queueing server is implemented using SimpleXMLRPCServer. What I try to do in the server __ init __ file is the following:
server = threading.Thread(target=queue_server.server_start(
'localhost', '8000', 'True'))
server.daemon=True
server.start()
The function that gets called when starting the thread is the following:
def server_start(hostname, port, debug):
debug = debug
server = SimpleXMLRPCServer((hostname, int(port)), allow_none=True)
server.register_function(kill, 'kill')
server.register_function(listen_for_tasks, 'update')
queue_consumer = threading.Thread(target=consumer)
queue_consumer.daemon = True
queue_consumer.start()
print 'Serving'
while not quit:
server.handle_request()
The problem is that as I expected the execution of code stops when I get to server.handle_request(), so the original server (Pyramid based one) doesn't get started, and neither does the process that should contain this secondary server. Is there a way to overcome this? I'm by no means an expert on multithreading, so the problem could very well reside in how I'm handling the generation of threads, any help is greatly appreciated!