Skip to content

Commit

Permalink
Don't call Scheduler#close if it doesn't exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Oct 1, 2020
1 parent bc23216 commit 1366010
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scheduler.c
Expand Up @@ -39,7 +39,9 @@ Init_Scheduler(void)

VALUE rb_scheduler_close(VALUE scheduler)
{
return rb_funcall(scheduler, id_close, 0);
if (rb_respond_to(scheduler, id_close)) {
return rb_funcall(scheduler, id_close, 0);
}
}

VALUE
Expand Down
8 changes: 8 additions & 0 deletions test/fiber/test_scheduler.rb
Expand Up @@ -49,4 +49,12 @@ def test_close_at_exit
end
RUBY
end

def test_optional_close
thread = Thread.new do
Thread.current.scheduler = Object.new
end

thread.join
end
end

0 comments on commit 1366010

Please sign in to comment.