diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-07-18 21:10:08 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-07-18 21:10:08 -0700 | 
| commit | db1e35497de924c001f421d1d3277f02258b55db (patch) | |
| tree | b31ceb9e6a34238ec2ede4ac97b312b4f7b73939 /continuedev/src/continuedev/server | |
| parent | eb90c79f618eab774af958ebee212150dead2467 (diff) | |
| download | sncontinue-db1e35497de924c001f421d1d3277f02258b55db.tar.gz sncontinue-db1e35497de924c001f421d1d3277f02258b55db.tar.bz2 sncontinue-db1e35497de924c001f421d1d3277f02258b55db.zip  | |
psutil profiling, temperature in config.json
Diffstat (limited to 'continuedev/src/continuedev/server')
| -rw-r--r-- | continuedev/src/continuedev/server/main.py | 25 | 
1 files changed, 24 insertions, 1 deletions
diff --git a/continuedev/src/continuedev/server/main.py b/continuedev/src/continuedev/server/main.py index aa093853..42dc0cc1 100644 --- a/continuedev/src/continuedev/server/main.py +++ b/continuedev/src/continuedev/server/main.py @@ -1,5 +1,6 @@ +import time +import psutil  import os -import sys  from fastapi import FastAPI  from fastapi.middleware.cors import CORSMiddleware  from .ide import router as ide_router @@ -51,9 +52,31 @@ def cleanup():          session_manager.persist_session(session_id) +def cpu_usage_report(): +    process = psutil.Process(os.getpid()) +    # Call cpu_percent once to start measurement, but ignore the result +    process.cpu_percent(interval=None) +    # Wait for a short period of time +    time.sleep(1) +    # Call cpu_percent again to get the CPU usage over the interval +    cpu_usage = process.cpu_percent(interval=None) +    print(f"CPU usage: {cpu_usage}%") + +  atexit.register(cleanup) +  if __name__ == "__main__":      try: +        # import threading + +        # def cpu_usage_loop(): +        #     while True: +        #         cpu_usage_report() +        #         time.sleep(2) + +        # cpu_thread = threading.Thread(target=cpu_usage_loop) +        # cpu_thread.start() +          run_server()      except Exception as e:          cleanup()  | 
