From: Fredrik Tolf Date: Sun, 5 May 2013 00:16:21 +0000 (+0200) Subject: Added a fileno function on imgstreams, for polling. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=af7300680e36fb1280cf248b897069ae5af18b08;p=automanga.git Added a fileno function on imgstreams, for polling. --- 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()