1

One of the clear advantages of LISP environments (Clojure etc) is the ability to hook up and get a Read-eval-print-loop (REPL) on a running instance - thus being able to call production code and generally interact with the production system at runtime - via the REPL.

I am currently working with a Python/Pyramid stack that is deployed on top of Nginx/Phusion passenger - and I find myself many times being forced to "perform live surgery" on the DB, when in fact I would much prefer to call a function that exists inside the deployed Python code...

Is there a possibility to get a production-attached REPL for my setup?

Thanks in advance for any pointers.

cfrick
  • 35,203
  • 6
  • 56
  • 68
ttsiodras
  • 10,602
  • 6
  • 55
  • 71

3 Answers3

3

I don't think there is a simple way to REPL in the same process, but you are probably looking for pshell.

pshell production.ini
Antoine Leclair
  • 17,540
  • 3
  • 26
  • 18
  • Thanks, Antoine. I gather that this is used at launch time (instead of e.g. pserve) during debug sessions - but can not be used to attach to a production instance. Correct? – ttsiodras Jul 22 '15 at 15:17
  • Correct, you cannot attach to a process using it. At least, if you can, I don't know how. But you can run it while the production application is running, as a separate process. It may be useful if you want to query the database for example. – Antoine Leclair Jul 22 '15 at 15:29
1

You can use PyCharm to attach to running Python process:

PyCharm makes it possible to attach to a Python process, while running a Python script launched either outside of PyCharm, or inside PyCharm

Also, take a look at these questions:
How do I attach a remote debugger to a Python process?
python: is it possible to attach a console into a running process

Community
  • 1
  • 1
Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
1

If you want to fancy try pyramid_notebook. It gives you IPython Notebook shell for your Pyramid website - Notebook being pretty much the culmination of 40 years of shell user interface development. It's more complex to set up, but once done, you get a interactive, secure, shell session your web browser with a single click.

Disclaimer: I am the author of the project.

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435