W3cubDocs

/Ruby 4.0

class Ractor::ClosedError

Parent:
StopIteration

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.

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.

Ruby Core © 1993–2025 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.