How to modify a program while it's running?

Arnaud Delobelle arnodel at
Tue Dec 16 22:14:44 CET 2008

Joe Strout <joe at> writes:

> Here's my situation: I'm making an AIM bot, but the AIM server will
> get annoyed if you log in too frequently (and then lock you out for a
> while).  So my usual build-a-little, test-a-little methodology doesn't
> work too well.
> 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?
> Thanks,
> - Joe

You could have two processes: the first one that logs in and does the message
passing with the server, the other that implements the logic and talks
to the server via the first one.  This way you can restart the second
one as often as you want without being logged out.

I never user reload() but I hear that it has quite a few caveats.


More information about the Python-list mailing list