Source

pypy / pypy / tool / isolate_slave.py

The branch 'stm-gc' does not exist.
import autopath
import sys, imp
from pypy.tool import slaveproc

class IsolateSlave(slaveproc.Slave):
    mod = None

    def do_cmd(self, cmd):
        cmd, data = cmd
        if cmd == 'load':
            assert self.mod is None
            mod = data
            if isinstance(mod, str):
                mod = __import__(mod, {}, {}, ['__doc__'])
            else:
                dir, name = mod
                file, pathname, description = imp.find_module(name, [dir])
                try:
                    mod = imp.load_module(name, file, pathname, description)
                finally:
                    if file:
                        file.close()
            self.mod = mod
            return 'loaded'
        elif cmd == 'invoke':
            assert self.mod is not None
            func, args = data
            try:
                res = getattr(self.mod, func)(*args)
            except KeyboardInterrupt:
                raise
            except:
                exc_type = sys.exc_info()[0] 
                return ('exc', (exc_type.__module__, exc_type.__name__))
            else:
                return ('ok', res)
        else:
            return 'no-clue'

if __name__ == '__main__':
    IsolateSlave().do()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.