SimpleXMLRPCServer and Blender

I need to run a SimpleXMLRPCServer in blender-2.57, but it stops at the line “serve_forever()”.

The code is:


from xmlrpc.server import SimpleXMLRPCServer 
from xmlrpc.server import SimpleXMLRPCRequestHandler 
 
class RequestHandler(SimpleXMLRPCRequestHandler): 
    rpc_paths = ('/RPC2',) 
 
server = SimpleXMLRPCServer(("localhost", 8000),requestHandler=RequestHandler) 
 
server.register_introspection_functions() 
 
class MyFuncs: 
    def mul(self, x, y): 
        return x * y 
 
server.register_instance(MyFuncs()) 
server.serve_forever() 

Please, help me to make it run.

I assume you want it to return control to blender (since it ‘works’ as is)?

Yes, do you know how?

You could run it as a thread.

I made SimpleXMLRPCServer to run in a thread like this:

server_thread = threading.Thread(target=server.serve_forever)
server_thread.setDaemon(True)
server_thread.start()

But now I have another problem. Let’s say that in function “mul” I have something like: bpy.context.active_object. Than comes an error “‘Context’ object has no attribute ‘active_object’”. It turns out that i do not have full access to blender objects in the thread.

From bpy.context i have only access to:

doc’, ‘module’, ‘slots’, ‘area’, ‘bl_rna’, ‘blend_data’, ‘copy’, ‘mode’, ‘region’, ‘region_data’, ‘rna_type’, ‘scene’, ‘screen’, ‘space_data’, ‘tool_settings’, ‘user_preferences’, ‘window’, ‘window_manager’

How can i start a SimpleXMLRPCServer without stopping blender to run?