def open_only(f):
  "decorator"
  @functools.wraps(f)
  def f2(self, *args, **kwargs):
    if self.closed: raise NotSupportedError('connection is closed')
    return f(self, *args, **kwargs)
  return f2
decorator