tags:

views:

178

answers:

2

I have a multit-threaded xmlrpc service running which stores a huge amount of data ~2G in memory. Currently, if I want to update a method the server exposes I have to restart the service. The problem here is that if I restart the service it needs to load all of the data it had in memory back into memory by using a database or using shelved data.

I am using methods like this:

xmlrpc_getUser(self, uid):
    return self.users[uid]

What I was hoping I could do is just use these methods as a proxy to another module, so my methods would look more like this

xmlrpc_getUser(self, uid):
    return self.proxy.getUser(uid)

This way I could update code on the development server then simply copy my update proxy module to the production server without the need for a restart.

I tried adding import service_proxy to the constructor of my xmlrpc service controller, but I think the module is cached and won't reload.

Is there a good way to do this? Thanks.

+3  A: 

You could use the reload method. You would need to write some code to check the last modified time of the modules file.

Gary van der Merwe
A: 

If reload doesn't work, you could try twisted.python.rebuild; your application need not be written in Twisted to use this twisted.python utility.

I also recently saw this livecoding thing ("a code reloading library for Python"), but it talks about a custom module system and I don't know what's going on there.

keturn