Project

General

Profile

Actions

Bug #17666

closed

Thread#join hangs when Fiber.set_scheduler is set

Added by arjunmdas (arjun das) about 1 year ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
[ruby-core:102687]

Description

class MockScheduler
  def block(blocker, timeout = nil)
    byebug
  end

  def close
    byebug
  end

  def fiber(&block)
    byebug
    Fiber.new(blocking: false, &block).tap(&:resume)
  end

  def io_wait(io, events, timeout)
    byebug
  end

  def kernel_sleep(duration=nil)
    byebug
    Fiber.yield
  end

  def process_wait(pid, flags)
    byebug
  end

  def unblock(blocker, fiber)
    byebug
  end
end
  
Fiber.set_scheduler(MockScheduler.new)

t1 = Thread.new do
       p 'before'
       sleep 1
       p 'after'
     end

t1.join

Code hangs at this point.

Actions

Also available in: Atom PDF