Skip to content
← Back to Community
Programmatically restart repl
Profile icon
Pandapip2

Hello! I am looking for a way to programmatically restart the repl running the program. There are three threads, one running the physics engine daemon (marked daemon=True), a flask server (it, as far as I know, uses a separate thread), and the main thread which restarts the others. Currently, I have working code (at the bottom of main.py) that restarts the Python program, but I believe there are memory leaks that cause the program to stay sluggish even after restarting. Is there a way to fully restart the repl (like os.system("kill 1")) but run the repl directly afterward? As far as I know, this is impossible, but if it is I would love to know!

Answered by RomeroSchwarz [earned 5 cycles]
View Answer
Voters
Profile icon
cohbev
Profile icon
GavinWang9
Profile icon
Pandapip2
Comments
hotnewtop
Profile icon
RomeroSchwarz

By terminating the repl, it stops the program, and thus cannot restart itself. There might be a way around this:

  • Create a program (program1), probably in bash
  • Use program1 to run this program (glap-io)
  • Once glap-io ends, have program1 restart it.
  • Repeat if necessary

If this post helped, mark it as the answer

Profile icon
Pandapip2

I don't know if this will work, but I will mark it as the answer for now.

Profile icon
Pandapip2

OK, so I created a repl to restart the other repl. This seems to currently work: https://repl.it/@Pandapip2/glapio-restarter

Profile icon
freddy2231

@Pandapip2 could you explain how you got this to work? I want to try this but I want to make it restart my repl when it crashes.