Python Hot-Loading Prototype

October 24, 2010

I’ve posted an initial prototype of an in-place module reloader (hot). Reloading using hot.reload provides several benefits over the reload method in imp:

  1. References to classes and functions defined in the module will be fixed up in-place to point to equivalent objects in the new module.
  2. Modules are cleaned before reloading so errors caused by referencing stale symbols will be caught sooner.
  3. Multiple modules can be reloaded at one time.
  4. If exceptions are thrown while reloading, all modules are rolled back to a clean state.

Read the rest...

In-Place Python Reloading

October 19, 2010

In order to improve the rate of development iteration, several languages have support for modifying functions and data structures without terminating the runtime environment. Python’s built-in reload method provides some support for this workflow, and is often suitable for simple use cases when iterating in the interactive shell.

Unfortunately, for longer-lived applications such as web servers or persistent simulations, the built-in reload method suffers from several limitations. In particular, only a single module may be reloaded at a time, and objects and other modules may continue to refer to elements of the old module, causing inconsistent behavior.

This document proposes a secondary extended reloading reloading mechanism that addresses some of these limitations. The general approach of this proposal is to fix up modified types and functions in-place using an extension of the GC module.

Read the rest...

Archive

2010


Copyright © 2001 - 2010 Peter Ingebretson unless otherwise noted.