Browse Source

Merge pull request #486 from dtnewman/restore-cursor

restore the cursor to the terminal on exit from CLI
Alex Cheema 5 months ago
parent
commit
f38cd55565
1 changed files with 8 additions and 0 deletions
  1. 8 0
      exo/main.py

+ 8 - 0
exo/main.py

@@ -1,5 +1,6 @@
 import argparse
 import asyncio
+import atexit
 import signal
 import json
 import logging
@@ -215,6 +216,13 @@ async def main():
     except Exception as e:
       print(f"Error moving models to .cache/huggingface: {e}")
 
+  def restore_cursor():
+    if platform.system() != "Windows":
+        os.system("tput cnorm")  # Show cursor
+
+  # Restore the cursor when the program exits
+  atexit.register(restore_cursor)
+
   # Use a more direct approach to handle signals
   def handle_exit():
     asyncio.ensure_future(shutdown(signal.SIGTERM, loop, node.server))