docs: def JSONObjectWriter(registry, fo, host=None):
      """Sink; writes object as JSON to a file.
  
      :param registry: serialisation registry.
      :param fo: output file.
      :param host: name of the host that encodes the JSON. This is relevant if
          the encoded data refers to external files for mass storage.
  
      In normal use, it may occur that the pipe to which we write is broken,
      for instance when the remote process shuts down. In that case, this
      coroutine exits.
      """
      while True:
          obj = yield
          try:
              print(registry.to_json(obj, host=host), file=fo, flush=True)
          except BrokenPipeError:
              return