diff options
-rw-r--r-- | paramiko/channel.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/paramiko/channel.py b/paramiko/channel.py index ae1a06fd..38772283 100644 --- a/paramiko/channel.py +++ b/paramiko/channel.py @@ -43,16 +43,27 @@ from paramiko import pipe # lower bound on the max packet size we'll accept from the remote host MIN_PACKET_SIZE = 1024 + def requires_open_channel(func): - """This decorator makes sure that the channel is open, else it raises an - SSHException.""" + """ + Decorator for `.Channel` methods which performs an openness check. + + :raises SSHException: + If the wrapped method is called on an unopened `.Channel`. + """ @wraps(func) def _check(self, *args, **kwds): - if self.closed or self.eof_received or self.eof_sent or not self.active: + if ( + self.closed + or self.eof_received + or self.eof_sent + or not self.active + ): raise SSHException('Channel is not open') return func(self, *args, **kwds) return _check + class Channel (object): """ A secure tunnel across an SSH `.Transport`. A Channel is meant to behave |