ionelmc / python-manhole

Debugging manhole for python applications.
https://pypi.python.org/pypi/manhole
BSD 2-Clause "Simplified" License
374 stars 24 forks source link

User defined locals in manhole shell #17

Closed nirs closed 10 years ago

nirs commented 10 years ago

Typically, when you add a manhole to existing application, the application was not designed for this, so finding stuff from the manhole shell is hard or even impossible.

This patch adds a new locals optional argument, allowing a user to add application specific objects to manhole shell locals.

Example usage:

manhole.install(locals={'server', my_server})

From the manhole shell, you can now use "server":

>>> server.status()

Installed locals are not inherited by child processes, since they may be invalid in the child process.

Issue: #16

coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.14%) when pulling d7b70cb1227b1dbc5e0d1802fe52a1787487598b on nirs:locals into a3b9e84077d7410b5f4eb467d4ef6f0ac0ffdc90 on ionelmc:master.

ionelmc commented 10 years ago

Looks good. Just a quick question wrt inheriting the locals on reinstall, what if people put utilities (like a get_memory_stats) in the locals? They would want those to be inherited.

nirs commented 10 years ago

Ok, looks like it is the user responsibility. If you are enable automatic installation in child process, you are responsible to use the locals correctly.

I'll post another version, this should make the code much simpler.

nirs commented 10 years ago

I posted a new version that support locals inheritance #18.