Added a fileno function on imgstreams, for polling.
authorFredrik Tolf <fredrik@dolda2000.com>
Sun, 5 May 2013 00:16:21 +0000 (02:16 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Sun, 5 May 2013 00:16:21 +0000 (02:16 +0200)
manga/lib.py
manga/mangafox.py

index e7c531c..8ec9c2e 100644 (file)
@@ -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()
index 8da9e10..339ed5e 100644 (file)
@@ -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()