Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow other threads like pry #142

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## Master (Unreleased)

### Fixed

* Allow other threads like Pry. (#142)

## 3.5.0 (2017-08-23)

### Added
Expand Down
2 changes: 1 addition & 1 deletion lib/byebug/processors/pry_processor.rb
Expand Up @@ -25,7 +25,7 @@ def run(&_block)
return_value = nil

command = catch(:breakout_nav) do # Throws from PryByebug::Commands
return_value = yield
return_value = allowing_other_threads { yield }
{} # Nothing thrown == no navigational command
end

Expand Down
12 changes: 12 additions & 0 deletions test/examples/echo_thread.rb
@@ -0,0 +1,12 @@
require 'socket'

client, server = Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM)

Thread.new do
while (line = server.readline)
server.write(line)
end
end

binding.pry
client
20 changes: 20 additions & 0 deletions test/thread_lock_test.rb
@@ -0,0 +1,20 @@
require 'test_helper'
require 'timeout'

class ThreadLockTest < MiniTest::Spec
let(:output) { StringIO.new }
let(:input) { InputTester.new }

describe "when there's another thread" do
before do
input.add 'client.puts("Hello")'
input.add 'IO.select([client], [], [], 1) && client.readline'

redirect_pry_io(input, output) { load test_file('echo_thread') }
end

it "another thread isn't locked" do
assert_equal "=> \"Hello\\n\"\n", output.string.lines.last
end
end
end