Ruby yaml and end-of-doc marker

I’m working on an application that does some IPC by passing yaml via sockets.
I ran into a deadlock caused by the situation addressed in this quote from
yaml.org:

···

When YAML is used as the format for a communication stream, it is useful to
be able to indicate the end of a document independent of starting the next
one without closing the data stream. Lacking such a marker, the YAML
processor reading the stream would be forced to wait for the header of the
next document (that may be long time in coming) in order to detect the end of
the previous document. To support this scenario, a YAML document may be
terminated by a “…” line.

As far as I can tell, methods to_yaml and YAML::parse() do not seem to support
this method of asynchronous document separation. To work around this, I’m
sending the “…” terminator (after to_yaml) at one end of the socket and
scanning for it manually at the other end, invoking YAML::load on a string of
accumulated yaml. This is working fine, but I’d like to request that ruby
yaml be made aware of the end-of-doc marker. Or perhaps it’s already so aware
and someone can steer me straight. Thanks in advance.


Pete Yadlowsky
ITC Unix Systems Support
University of Virginia