Restarting application, keep PyCharm attached

Hi all,

I've created a long-running application that has a memory leak in it. Rather than spend time on finding & fixing a complex bug in an even more complex program, I've written a bit of code to restart the application in case a memory error occurs:

Rebooting code
def reboot(self):
    '''Launches another instance of RAGE, then quits this application.'''

    new_rage = subprocess.Popen([sys.executable] + sys.argv,
  cwd=run_settings.RAGE_HOME,
  start_new_session=True)

    try:
        # Give the new process time to start before we close.
        # If we quit too quickly the new process won't start either.
        new_rage.wait(timeout=2)
        self.log.error('Unable to start a new RAGE instance. Just quitting.')
    except subprocess.TimeoutExpired:
        # This is expected.
        pass

    self.quit()



This works just fine, except that PyCharm (correctly) assumes the program has stopped. It then no longer logs the output of the new program instance, so that program's stdout/err are nowhere to be seen.

Is there a way in which I can close the current process and start a new one, while keeping PyCharm attached to the new process?

Thanks in advance for any help,
Sybren
0

Please sign in to leave a comment.