From 238b1808c19df4efc981cef1826a2e886684849a Mon Sep 17 00:00:00 2001 From: Liam Childs Date: Mon, 26 Sep 2016 17:12:46 +0200 Subject: [PATCH] added is_closed and is_open to input --- mimo/connection/input.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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()