'Re-execute the current process.
This must be called from the main thread, because certain platforms
(OS X) don\'t allow execv to be called in a child thread very well.'

def _do_execv(self):

    args = sys.argv[:]
    self.log(('Re-spawning    %s' % '    '.join(args)))
    if (sys.platform[:4] == 'java'):
        from _systemrestart import SystemRestart
        raise SystemRestart
    else:
        args.insert(0, sys.executable)
        if (sys.platform == 'win32'):
            args = [('"%s"' % arg) for arg in args]
        os.chdir(_startup_cwd)
        if self.max_cloexec_files:
            self._set_cloexec()
        os.execv(sys.executable, args)
