Pool finalization sometimes raises exception during GC
I'm getting weird exceptions during my application exiting: Exception TypeError: "'NoneType' object is not callable" in <function <lambda> at 0x10389cb18> ignored ... Exception TypeError: "'NoneType' object is not callable" in <function <lambda> at 0x10389c398> ignored
This is due to finalization of _ConnectionFairy weakref which doesn't check if _finalize_fairy is still here.
Comments (7)
-
reporter -
repo owner - changed milestone to 0.7.5
weird, you mean after the module tears down it's called ? can't do the "x if y else z" due to py2.4, but anyway how about this:
diff -r 996d3916a33dfaa90bc59a1545c6c492fdf4aa1a lib/sqlalchemy/pool.py --- a/lib/sqlalchemy/pool.py Mon Jan 23 16:35:16 2012 -0500 +++ b/lib/sqlalchemy/pool.py Mon Jan 23 18:22:15 2012 -0500 @@ -370,9 +370,10 @@ try: rec = self._connection_record = pool._do_get() conn = self.connection = self._connection_record.get_connection() + _f_f = _finalize_fairy rec.fairy = weakref.ref( self, - lambda ref:_finalize_fairy(conn, rec, pool, ref, _echo) + lambda ref:_f_f(conn, rec, pool, ref, _echo) ) _refs.add(rec) except:
-
reporter No, this doesn't work for me either:
Exception AttributeError: "'NoneType' object has no attribute 'discard'" in <function <lambda> at 0x1038fa938> ignored
but this does and compatible with py2.4:
... rec.fairy = weakref.ref( self, lambda ref: _finalize_fairy and _finalize_fairy(conn, rec, pool, ref, _echo) ) ...
-
repo owner this is really annoying that even a weakref needs to doubt local variables in it's own callback - what version of Python /platform is this ?
also you are going to fix your app to close the connection, right ? :)
-
reporter Python 2.6.2/2.7.1 on FreeBSD/Mac OS X, and I've already fixed app to close connections. :-)
-
repo owner - changed status to resolved
-
repo owner - removed milestone
Removing milestone: 0.7.5 (automated comment)
- Log in to comment
Oops, sorry for description formatting.