Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Fiber.blocking?

Fiber.blocking? → false or number

Returns false if the current fiber is non-blocking. Fiber is non-blocking if it was created via passing blocking: false to Fiber.new, or via Fiber.schedule.

If the current Fiber is blocking, the method, unlike usual predicate methods, returns a number of blocking fibers currently running (TBD: always 1?).

Note, that even if the method returns false, Fiber behaves differently only if Fiber.scheduler is set in the current thread.

See the “Non-blocking fibers” section in class docs for details.

Ruby version changes

  1. 3.0
See also #blocking? .current .new also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1