[pypy-svn] r14017 - pypy/dist/pypy/translator/goal
arigo at codespeak.net
arigo at codespeak.net
Thu Jun 30 00:23:52 CEST 2005
Author: arigo
Date: Thu Jun 30 00:23:50 2005
New Revision: 14017
Added:
pypy/dist/pypy/translator/goal/unixcheckpoint.py (contents, props changed)
Modified:
pypy/dist/pypy/translator/goal/translate_pypy.py
Log:
This is a quick fork() hack that seems to provide a robust alternative to
pickling on Unix systems. The process forks a copy of itself after annotation
and runs the rtyper in the subprocess. When the subprocess terminates, the
parent process prompts you again and let you fork another copy to re-run the
rtyper. All modules not imported before the checkpoint can be modified
between the runs (that's only the rtyper, essentially).
Modified: pypy/dist/pypy/translator/goal/translate_pypy.py
==============================================================================
--- pypy/dist/pypy/translator/goal/translate_pypy.py (original)
+++ pypy/dist/pypy/translator/goal/translate_pypy.py Thu Jun 30 00:23:50 2005
@@ -17,6 +17,7 @@
-no-t Don't type-specialize the graph operations with the C typer
-no-o Don't do backend-oriented optimizations
-no-c Don't generate the C code
+ -fork (UNIX) Create a restartable checkpoint after annotation
-c Generate the C code, but don't compile it
-o Generate and compile the C code, but don't run it
-tcc Equivalent to the envvar PYPY_CC='tcc -shared -o "%s.so" "%s.c"'
@@ -70,7 +71,6 @@
from pypy.annotation.model import SomeObject
from pypy.tool.udir import udir
from pypy.tool.ansi_print import ansi_print
-from pypy.rpython.rtyper import RPythonTyper
from pypy.translator.pickle.main import load, save
# XXX this tries to make compiling faster
@@ -104,6 +104,9 @@
if a and not options['-no-s']:
print 'Simplifying...'
a.simplify()
+ if a and options['-fork']:
+ from pypy.translator.goal import unixcheckpoint
+ unixcheckpoint.restartable_point()
if a and not options['-no-t']:
print 'Specializing...'
t.specialize()
@@ -257,6 +260,7 @@
'-no-d': False,
'-load': False,
'-save': False,
+ '-fork': False,
}
listen_port = None
argiter = iter(sys.argv[1:])
Added: pypy/dist/pypy/translator/goal/unixcheckpoint.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/goal/unixcheckpoint.py Thu Jun 30 00:23:50 2005
@@ -0,0 +1,51 @@
+import os
+
+def restartable_point():
+ while True:
+ while True:
+ print '---> Checkpoint: run / quit / pdb ?'
+ try:
+ line = raw_input().strip().lower()
+ except KeyboardInterrupt:
+ print '(KeyboardInterrupt ignored)'
+ continue
+ if line == 'run':
+ break
+ if line == 'quit':
+ raise SystemExit
+ if line == 'pdb':
+ import pdb; pdb.set_trace()
+
+ pid = os.fork()
+ if pid != 0:
+ # in parent
+ while True:
+ try:
+ pid, status = os.waitpid(pid, 0)
+ except KeyboardInterrupt:
+ continue
+ else:
+ break
+ print
+ print '_'*78
+ print 'Child %d exited' % pid,
+ if os.WIFEXITED(status):
+ print '(exit code %d)' % os.WEXITSTATUS(status)
+ elif os.WIFSIGNALED(status):
+ print '(caught signal %d)' % os.WTERMSIG(status)
+ else:
+ print 'abnormally (status 0x%x)' % status
+ continue
+
+ # in child
+ print '_'*78
+ break
+
+
+if __name__ == '__main__':
+ print 'doing stuff...'
+ print 'finished'
+ restartable_point()
+ print 'doing more stuff'
+ print 'press Enter to quit...'
+ raw_input()
More information about the Pypy-commit
mailing list