pry-remote
pry-remote copied to clipboard
Continue execution with pry-remote
In Rails (3.1.1) running on Pow, when I pause execution with binding.remote_pry and then remote in with pry-remote, execution does not continue after I exit
the pry session. If I pry-remote back in, I'm at the same place. How to continue program execution in this scenario?
Could you provide an example script to reproduce? I don't have this issue with this (trivial) sample script:
require 'pry-remote'
class Foo
def initialize(x, y)
binding.remote_pry "0.0.0.0"
puts 3
end
end
Foo.new 10, 20
Doing exit works for me. What doesn't work is doing cd .. to continue to the next, which works with normal binding.pry and saves you having to exit and come back in....
Right, I see what you mean. It "just works" in Pry because it runs in the same process. In this case, you don't know whether or not the process is still running after each step. I guess one way to implement that would be having the pry'd program send some message to the client upon exit (e.g. using an at_exit hook).
My concern is in the other direction. I've got two processes: pry-remote in a console, and my rails app under pow. I put a "binding.remote_pry" in the rails app, and start a request with a browser. I run "pry-remote" in the console and do get connected to that running program, where I can examine variables and such. But then I don't see how to continue execution. If I ^D or 'exit' the rails app raises an exception so I can't continue after. 'cd ..' doesn't seem to do anything, I wind up where I started every time.
Is there a way to continue execution of the pry'd process?
I haven't been able to find a way to gracefully disconnect the pry-remote client from the server without an exception being raised. My workaround is to set the breakpoints as follows:
require 'pry-remote'; binding.remote_pry rescue DRb::DRbConnError
When I quit pry, the application continues running without the exception unwinding the stack.
As mentionned before, leaving the above script with both exit
and ^D
resumes the execution of the program.
johanadamson: Btw, binding.remote_pry rescue DRb::DRbConnError
does not rescue DRb::DRbConnError
s, it rescues StandarException
s, in which case it evaluates to DRb::DRbConvError
.
mon-ouie: Yes, you are right, my mistake. rescue
as a statement modifier will rescue all errors descended from StandardError.