1. Aldona Majorek
  2. eventlet-py3k


amajorek  committed 9b9c516

Fixed incompatibilities with os module.
- os.fdopen should raise OSError, not IOError.

  • Participants
  • Parent commits ff64582
  • Branches default

Comments (0)

Files changed (2)

File eventlet/green/os.py

View file
     Return an open file object connected to a file descriptor."""
     if not isinstance(fd, int):
         raise TypeError('fd should be int, not %r' % fd)
-    return greenio.GreenPipe(fd, *args, **kw)
+    try:
+        return greenio.GreenPipe(fd, *args, **kw)
+    except IOError, e:
+        raise OSError(*e.args)
 __original_read__ = os_orig.read
 def read(fd, n):

File eventlet/greenio.py

View file
                     raise IOError(*e.args)
     def __del__(self):
-        os.close(self._fileno)
+        try:
+            os.close(self._fileno)
+        except:
+            # os.close may fail if __init__ didn't complete (i.e file dscriptor passed to popen was invalid
+            pass
     def __repr__(self):  
         return "%s:%d" % (self.__class__.__name__, self._fileno)