Live data from Hacker News

Interactive shell to a running Python process

github.com

11–20 of 23 posts

Re: Interactive shell to a running Python process

#11

Very interesting. I would love to see this for other programming languages, especially Ruby (probably fairly easy) or Objective-C (may be quite hard).

For ObjC:

https://github.com/albertz/Pyjector (and then access the ObjC runtime via the Python ObjC bridge)

https://github.com/albertz/FScriptAnywhereSIMBL

Re: Interactive shell to a running Python process

#12

What are the consequences of running this in production? What's the performance hit like, is it unsafe, etc.?

We've been using rfoo to do this. It doesn't seem to impact performance when you're not using it. When you are using it, it's unsafe if you do unsafe things. We primarily use it for debugging by passively inspecting the messed-up portion of the server's state.

Re: Interactive shell to a running Python process

#14

Very interesting. I would love to see this for other programming languages, especially Ruby (probably fairly easy) or Objective-C (may be quite hard).

For ObjC: https://github.com/albertz/Pyjector (and then access the ObjC runtime via the Python ObjC bridge) https://github.com/albertz/FScriptAnywhereSIMBL

Or Cycript, which all of us iOS hackers use. ;P

http://www.cycript.org/ http://iphonedevwiki.net/index.php/Cycript

Re: Interactive shell to a running Python process

#15

Very interesting. I would love to see this for other programming languages, especially Ruby (probably fairly easy) or Objective-C (may be quite hard).

Objective-C also has Cycript at http://cycript.org/, which has a hybrid syntax of JavaScript and Objective-C and supports injecting into any running process.b

Re: Interactive shell to a running Python process

#16

What are the consequences of running this in production? What's the performance hit like, is it unsafe, etc.?

> is it unsafe, etc.?

As the readme notes, it's completely unsafe if you perform any mutation operation.

As to the performance hit, I'd expect almost none when not in use for long-running processes: it spawns a thread, and that thread will then wait on a socket accept, no connection, no resources spent. You'll still be paying in memory for the server thread, but that's it (the server thread only creates two objects, an rlcompleter.Completer instance and a function).

Re: Interactive shell to a running Python process

#17

Very interesting. I would love to see this for other programming languages, especially Ruby (probably fairly easy) or Objective-C (may be quite hard).

It's dead easy in Node using the REPL module (http://nodejs.org/docs/v0.6.5/api/repl.html). I've used this to debug weird async issues.

Re: Interactive shell to a running Python process

#18

Very interesting. I would love to see this for other programming languages, especially Ruby (probably fairly easy) or Objective-C (may be quite hard).

Ruby's had the much more featureful Pry for some time now: http://github.com/pry/pry.

(And there have been various projects to provide some sub-capabilities for years.)

Re: Interactive shell to a running Python process

#19
I use ipython's "ipdb" or plain old Python "pdb" for the same functionality, and a bit more -- people don't seem to realize that ipdb gives them a full-on REPL within the calling context.

I usually wrap it into our error logging functions, so an environment variable enables debugging where I would normally have a catch-all -- very handy when looking for heisenbugs in AndBug.

AntiLog -- https://gist.github.com/a256ed1295619fad7cfc

AndBug -- https://github.com/swdunlop/andbug

Re: Interactive shell to a running Python process

#20

Very interesting. I would love to see this for other programming languages, especially Ruby (probably fairly easy) or Objective-C (may be quite hard).

Id like to see it in bash, all i know now is to use the +x option but you need to do it before its run
Post reply on HN