Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class · Ruby 4.1

Ractor::ClosedError

Raised when an attempt is made to send a message to a closed port, or to retrieve a message from a closed and empty port. Ports may be closed explicitly with Ractor::Port#close and are closed implicitly when a Ractor terminates.

Example
port = Ractor::Port.new
port.close
port << "test"  # Ractor::ClosedError
port.receive    # Ractor::ClosedError

ClosedError is a descendant of StopIteration, so the closing of a port will break out of loops without propagating the error.