Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug long running python scripts or services remotely?

Pretty much what the title says, I would like to be able to connect to a python process running under paster or uwsgi and utilize pdb functionality.

like image 932
Tony Avatar asked Nov 05 '22 16:11

Tony


1 Answers

Using winpdb, you can attach to a running process like this:

  1. Insert

    import rpdb2; rpdb2.start_embedded_debugger('mypassword')
    

    inside your script.

  2. Launch your script (through paster or uwsgi) as usual.
  3. Run winpdb
  4. Click File>Attach
  5. Type in password (e.g. "mypassword"), select the process.
  6. To detach, click File>Detach. The script will continue to run, and can be attached to again later.
like image 157
unutbu Avatar answered Nov 09 '22 10:11

unutbu