_internal.py 627 B

1234567891011121314151617181920212223242526272829303132
  1. import sys
  2. import atexit
  3. import os
  4. def restart():
  5. if "HIKKA_DO_NOT_RESTART" in os.environ:
  6. print("Got in a loop, exiting")
  7. sys.exit(0)
  8. print("🔄 Restarting...")
  9. atexit.register(
  10. lambda: os.execl(
  11. sys.executable,
  12. sys.executable,
  13. "-m",
  14. os.path.relpath(
  15. os.path.abspath(
  16. os.path.dirname(
  17. os.path.abspath(__file__),
  18. ),
  19. ),
  20. ),
  21. *(sys.argv[1:]),
  22. )
  23. )
  24. os.environ["HIKKA_DO_NOT_RESTART"] = "1"
  25. sys.exit(0)