diff --git a/eventlet/channel.py b/eventlet/channel.py index 80146e5..e15cc10 100644 --- a/eventlet/channel.py +++ b/eventlet/channel.py @@ -1,16 +1,23 @@ from eventlet import coros -class channel(coros.queue): - - def __init__(self): - coros.queue.__init__(self, 0) +class channel(coros.Channel): def receive(self): return self.wait() @property def balance(self): - return self.sem.balance + return len(self.items) - len(self._waiters) import warnings -warnings.warn("channel is deprecated; use coros.queue(0) which behaves the same", DeprecationWarning, stacklevel=2) +warnings.warn("channel.py is deprecated by coros.Channel", DeprecationWarning, stacklevel=2) + +if __name__ == '__main__': + from eventlet import proc, api + c = channel() + proc.spawn(c.send, 'X') + proc.spawn(c.send, 'Y') + assert c.wait() == 'X', c + assert c.wait() == 'Y', c + assert api.with_timeout(1, c.wait, timeout_value='hello') == 'hello', c +