diff --git a/mimo/connection/input.py b/mimo/connection/input.py index f68130f..9926c8e 100644 --- a/mimo/connection/input.py +++ b/mimo/connection/input.py @@ -27,7 +27,7 @@ async def push(self, item): async def peek(self): while self.empty(): - if self._closed and len(self._putters) == 0: + if self.is_closed(): raise ConnectionClosed getter = self._loop.create_future() @@ -71,3 +71,9 @@ def close(self): getter.set_exception(ConnectionClosed) else: getter.set_result(None) + + def is_closed(self): + return self._closed and len(self._queue) == 0 and len(self._putters) == 0 + + def is_open(self): + return not self.is_closed()