Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Docs

  • Loading branch information...
commit 17803f0bf0e6c98030f766f91a2f88b972bb7152 1 parent 2287ef7
@fabioz authored
Showing with 43 additions and 20 deletions.
  1. +43 −20 plugins/org.python.pydev/pysrc/pydevd_reload.py
View
63 plugins/org.python.pydev/pysrc/pydevd_reload.py
@@ -1,7 +1,8 @@
"""
Based on the python xreload.
-Changes:
+Changes
+======================
1. we don't recreate the old namespace from new classes. Rather, we keep the existing namespace,
load a new version of it and update only some of the things we can inplace. That way, we don't break
@@ -14,15 +15,19 @@
4. Reload hooks were changed
These changes make it more stable, especially in the common case (where in a debug session only the
-contents of a function are changed).
+contents of a function are changed), besides providing flexibility for users that want to extend
+on it.
-Hooks:
+
+Hooks
+======================
Classes/modules can be specially crafted to work with the reload (so that it can, for instance,
update some constant which was changed).
-1. Participate in change of attribute:
+
+1. To participate in the change of some attribute:
In a module:
@@ -38,37 +43,55 @@
-2. __xreload_after_reload_update__():
+2. To do something after the whole reload is finished:
+
+ In a module:
+
+ __xreload_after_reload_update__(namespace):
+
+ In a class:
+
+ @classmethod
+ __xreload_after_reload_update__(cls):
+
A class or module may include a method called '__xreload_after_reload_update__' which is called
after the reload finishes.
-Original: http://svn.python.org/projects/sandbox/trunk/xreload/xreload.py
-Note: it seems https://github.com/plone/plone.reload/blob/master/plone/reload/xreload.py enhances it (to check later)
+Current limitations
+======================
-Interesting alternative: https://code.google.com/p/reimport/
-Alternative to reload().
+- Attributes/constants are added, but not changed (so singletons and the application state is not
+ broken -- use provided hooks to workaround it).
+
+- Code using metaclasses may not always work.
+
+- Functions and methods using decorators (other than classmethod and staticmethod) are not handled
+ correctly.
+
+- Renamings are not handled correctly.
-This works by executing the module in a scratch namespace, and then
-patching classes, methods and functions in place. This avoids the
-need to patch instances. New objects are copied into the target
-namespace.
+- Dependent modules are not reloaded.
-Some of the many limitations include:
+- New __slots__ can't be added to existing classes.
-- Attributes/constants are added, but not changed (so singletons and the application state is not broken)
-- Code using metaclasses may not work always
+Info
+======================
-- Functions and methods using decorators (other than classmethod and staticmethod) are not handled correctly
+Original: http://svn.python.org/projects/sandbox/trunk/xreload/xreload.py
+Note: it seems https://github.com/plone/plone.reload/blob/master/plone/reload/xreload.py enhances it (to check later)
-- Renamings are not handled correctly
+Interesting alternative: https://code.google.com/p/reimport/
+
+Alternative to reload().
-- Dependent modules are not reloaded
+This works by executing the module in a scratch namespace, and then patching classes, methods and
+functions in place. This avoids the need to patch instances. New objects are copied into the
+target namespace.
-- New __slots__ can't be added to existing classes
"""
import imp
Please sign in to comment.
Something went wrong with that request. Please try again.