[pypy-svn] r18370 - pypy/dist/pypy/translator/goal

tismer at codespeak.net tismer at codespeak.net
Tue Oct 11 10:52:11 CEST 2005


Author: tismer
Date: Tue Oct 11 10:52:10 2005
New Revision: 18370

Modified:
   pypy/dist/pypy/translator/goal/driver.py
   pypy/dist/pypy/translator/goal/unixcheckpoint.py
Log:
added checkpoint support for windows.
You need to install some VM like VMware.
Then you can save a restartable snapshot
using fork-before.

Modified: pypy/dist/pypy/translator/goal/driver.py
==============================================================================
--- pypy/dist/pypy/translator/goal/driver.py	(original)
+++ pypy/dist/pypy/translator/goal/driver.py	Tue Oct 11 10:52:10 2005
@@ -339,8 +339,8 @@
                     prereq = getattr(self, 'prereq_checkpt_%s' % goal, None)
                     if prereq:
                         prereq()
-                        from pypy.translator.goal import unixcheckpoint
-                        unixcheckpoint.restartable_point(auto='run')
+                    from pypy.translator.goal import unixcheckpoint
+                    unixcheckpoint.restartable_point(auto='run')
 
 
 from pypy.translator.tool.util import mkexename, assert_rtyper_not_imported

Modified: pypy/dist/pypy/translator/goal/unixcheckpoint.py
==============================================================================
--- pypy/dist/pypy/translator/goal/unixcheckpoint.py	(original)
+++ pypy/dist/pypy/translator/goal/unixcheckpoint.py	Tue Oct 11 10:52:10 2005
@@ -1,12 +1,14 @@
-import os
+import os, sys
 
 def restart_process():
     import sys
     os.execv(sys.executable, [sys.executable] + sys.argv)
 
-def restartable_point(auto=None):
+def restartable_point_fork(auto=None, extra_msg=None):
     while True:
         while True:
+            if extra_msg:
+                print extra_msg
             print '---> Checkpoint: cont / restart / quit / pdb ?'
             if auto:
                 print 'auto-%s' % (auto,)
@@ -27,7 +29,11 @@
             if line == 'restart':
                 restart_process()
 
-        pid = os.fork()
+        try:
+            pid = os.fork()
+        except AttributeError:
+            # windows case
+            return
         if pid != 0:
             # in parent
             while True:
@@ -52,6 +58,18 @@
         print '_'*78
         break
 
+# special version for win32 which does not have fork() at all,
+# but epople can simulate it by hand using VMware
+
+def restartable_point_nofork(auto=None):
+    # auto ignored, no way to automate VMware, yet
+    restartable_point_fork(None, '+++ this system does not support fork +++\n'
+        'if you have a virtual machine, you can save a snapshot now')
+
+if sys.platform == 'win32':
+    restartable_point = restartable_point_nofork
+else:
+    restartable_point = restartable_point_fork
 
 if __name__ == '__main__':
     print 'doing stuff...'



More information about the Pypy-commit mailing list