Commit 36df7e06 authored by Jim Fulton's avatar Jim Fulton

Be more careful about calling close callbacks

By resetting self.__onCloseCallbacks before calling the close
callbacks to forestall infinite recursion (as can be the case when a
close callback is the database close methos).
parent baee84a6
...@@ -306,13 +306,14 @@ class Connection(ExportImport, object): ...@@ -306,13 +306,14 @@ class Connection(ExportImport, object):
# Call the close callbacks. # Call the close callbacks.
if self.__onCloseCallbacks is not None: if self.__onCloseCallbacks is not None:
for f in self.__onCloseCallbacks: callbacks = self.__onCloseCallbacks
self.__onCloseCallbacks = None
for f in callbacks:
try: try:
f() f()
except: # except what? except: # except what?
f = getattr(f, 'im_self', f) f = getattr(f, 'im_self', f)
self._log.exception("Close callback failed for %s", f) self._log.exception("Close callback failed for %s", f)
self.__onCloseCallbacks = None
self._debug_info = () self._debug_info = ()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment