Joe Strout <j...@strout.net> writes:
> 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?

If you are on Linux, an alternative might be to start a new version of
your program in a separate process, then transfer the open connections
from the old process to the new ones through Unix domain sockets.  The
SCM_RIGHTS message lets you pass file descriptors around between
processes.  I've never tried this myself but have always wanted to.  I
think someone submitted a patch for Python's socket module a year or
so ago to support that operation, but I don't know if it was accepted.
You could always apply it yourself.

Generally, trying to hot-patch code is messy and dangerous even in
systems that were designed for it.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to