Mon-Ouie / pry-remote

Connect to Pry remotely
Other
636 stars 81 forks source link

Continue execution with pry-remote #7

Open gavinhughes opened 12 years ago

gavinhughes commented 12 years ago

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?

Mon-Ouie commented 12 years ago

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
cj commented 12 years ago

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....

Mon-Ouie commented 12 years ago

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).

cluesque commented 11 years ago

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?

johnadamson commented 11 years ago

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.

Mon-Ouie commented 11 years ago

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::DRbConnErrors, it rescues StandarExceptions, in which case it evaluates to DRb::DRbConvError.

johnadamson commented 11 years ago

mon-ouie: Yes, you are right, my mistake. rescue as a statement modifier will rescue all errors descended from StandardError.