Just a quick note about signal handling. In the past, sending SIGUSR1 to a running yt-imported python task would print the stack and SIGUSR2 would make it raise a runtime error. I've changed this behavior, so that SIGUSR2 actually inserts an IPython session at the current location in the running task. When the IPython session terminates (ctrl-d) it will continue executing. This will let you do things like modify state variables, inspect state variables, etc etc.
I haven't added a convenience function for listing the surrounding code, but that shouldn't be too bad to do, and so if somebody wants to take that on it'd be great. I'd suggest just adding that function into the locals of the IPython session.