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

Explicitly catch NoMethodError instead of catching with Object when there are no events in queue #215

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/god/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def initialize(task)
loop do
begin
@events.pop.handle_event
rescue ThreadError => e
rescue ThreadError, NoMethodError => e
# queue is empty
break
rescue Object => e
Expand All @@ -189,6 +189,7 @@ def initialize(task)
end
end
end
@thread.abort_on_exception = true
end

# Check if we're in the driver context.
Expand Down
8 changes: 8 additions & 0 deletions test/test_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ def test_push_pop_wait

t.join
end

def test_handle_empty_queue
task = God::Task.new
driver = God::Driver.new(task)

events = driver.instance_variable_get(:@events)
assert events.shutdown
end
end