def close(self):
self.lock.acquire()<EOL>try:<EOL><INDENT>if self._pipe is not None:<EOL><INDENT>self._pipe.close()<EOL>self._pipe = None<EOL><DEDENT>if not self.active or self.closed:<EOL><INDENT>return<EOL><DEDENT>msgs = self._close_internal()<EOL><DEDENT>finally:<EOL><INDENT>self.lock.release()<EOL><DEDENT>for m in msgs:<EOL><INDENT>if m is not None:<EOL><INDENT>self.transport._send_user_message(m)<EOL><DEDENT><DEDENT>
Close the channel.  All future read/write operations on the channel
will fail.  The remote end will receive no more data (after queued data
is flushed).  Channels are automatically closed when their `.Transport`
is closed or when they are garbage collected.