Comment 13 for bug 855030

Revision history for this message
Vish Ishaya (vishvananda) wrote :

381 def cursor(self, *args, **kwargs):
382 try:
383 c = self.connection.cursor(*args, **kwargs)
384 return _CursorFairy(self, c)
385 except Exception, e:
386 self.invalidate(e=e)
387 raise

I expect the bare raise is here (sqlalchemy/pool.py). Pretty sure self.invalidate is making socket connections, so the exception is getting eaten by eventlet. I'm trying to investigate if there is a way to make eventlet not clear exception info. This could be especially dangerous if the higher level code is trying to catch a specific type of exception. Might be worth it to try one of the following things:

1) Try to make eventlet stop eating exception info:

diff -r f30a2fa65f30 eventlet/hubs/hub.py
--- a/eventlet/hubs/hub.py Wed Jun 08 23:47:26 2011 -0700
+++ b/eventlet/hubs/hub.py Sat Sep 24 05:04:30 2011 -0700
@@ -173,7 +173,7 @@
                 cur.parent = self.greenlet
         except ValueError:
             pass # gets raised if there is a greenlet parent cycle
- clear_sys_exc_info()
+ #clear_sys_exc_info()
         return self.greenlet.switch()

     def squelch_exception(self, fileno, exc_info):

or 2) modify the above code to reraise the exception

diff --git a/Library/Python/2.7/site-packages/sqlalchemy/pool.py b/pool.py
index 632d955..21e7055 100644
--- a/Library/Python/2.7/site-packages/sqlalchemy/pool.py
+++ b/pool.py
@@ -383,8 +383,10 @@ class _ConnectionFairy(object):
             c = self.connection.cursor(*args, **kwargs)
             return _CursorFairy(self, c)
         except Exception, e:
+ import sys
+ exc = sys.exc_info()
             self.invalidate(e=e)
- raise
+ raise exc

     def __getattr__(self, key):
         return getattr(self.connection, key)

I will do some more investigation into this when I can. We need a clear repro case for this.