How to modify a program while it's running?

James Mills prologic at shortcircuit.net.au
Tue Dec 16 20:35:53 EST 2008


On Wed, Dec 17, 2008 at 11:26 AM, Steven D'Aprano
<steve at remove-this-cybersource.com.au> wrote:
>> So I'd like to restructure my app so that it can stay running and stay
>> logged in, yet I can still update and reload at least most of the code.
>> But I'm not sure what's the best way to do this.  Should I move the
>> reloadable code into its own module, and then when I give my bot a
>> "reload" command, have it call reload on that module?  Will that work,
>> and is there a better way?
>
> That should work for functions, but less successfully with classes. The
> problem is that existing objects will still have the old behaviour even
> after reloading the class.

You need to build a subscribe/unsubscribe facility.
Or a plugin system :)

My IRC/Jabber bot kdb uses such features
and is capable of loading/unloading/reloading plugins on the fly.

YOu're welcome to borrow some of it's code :)

http://hg.softcircuit.com.au/projects/kdb/

cheers
James



More information about the Python-list mailing list