From af7300680e36fb1280cf248b897069ae5af18b08 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sun, 5 May 2013 02:16:21 +0200 Subject: [PATCH] Added a fileno function on imgstreams, for polling. --- manga/lib.py | 6 ++++++ manga/mangafox.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/manga/lib.py b/manga/lib.py index e7c531c..8ec9c2e 100644 --- a/manga/lib.py +++ b/manga/lib.py @@ -123,6 +123,12 @@ class imgstream(object): def __exit__(self, *exc_info): self.close() + def fileno(self): + """If reading the imgstream may block, fileno() should return + a file descriptor that can be polled. If fileno() returns + None, that should mean that reading will not block.""" + return None + def close(self): """Close this stream.""" raise NotImplementedError() diff --git a/manga/mangafox.py b/manga/mangafox.py index 8da9e10..339ed5e 100644 --- a/manga/mangafox.py +++ b/manga/mangafox.py @@ -8,6 +8,9 @@ class imgstream(lib.imgstream): self.bk = urllib.urlopen(url) self.ctype = self.bk.info()["Content-Type"] + def fileno(self): + return self.bk.fileno() + def close(self): self.bk.close() -- 2.11.0