Is where a way to persist objects over re-execs of a running script? If I want a running script to re execute itself to pick up any code changes, (os.exec*) is there a way to persist the objects for access after the re-execution? I could set environment variables with pickled ascii data, or write that data to a pipe and re-read it after the re-execution, but that seems inelegant or like a hack. Even if doing that, not all items pickle well.
Share
If you put your code in a module, you can use the
reload()standard function to load the new version of the code. Your main module could look like this:Whenever you want to reload your module code, return
Truefromgo(). When you want to exit, returnFalse.