#42 Exception raised in _close_physical_connection()

closed-fixed
5
2004-10-25
2004-08-18
No

When I try to close a database connection, I get the
message:

Exception exceptions.AttributeError: "'NoneType' object
has no attribute 'is_purportedly_open'" in <bound
method Connection.__del__ of <kinterbasdb.Connection
instance at 0x01B73D28>> ignored

This seems to be occuring during a *second* call to
_close_physical_connection() when it is called by the
connection's __del__ method, by which time _k is None.
The following patch seems to prevent it:

E:\PyDevSrc\Dp6_dev>svn diff
Index: 3rdPartyCode/kinterbasdb/__init__.py
===================================================================
--- 3rdPartyCode/kinterbasdb/__init__.py
(revision 43)
+++ 3rdPartyCode/kinterbasdb/__init__.py
(working copy)
@@ -880,7 +880,7 @@
# of that type, so that post-close() method
calls on this connection
# will raise ProgrammingErrors, as required by
the DB API Spec.
if hasattr(self, '_C_con'):
- if _k.is_purportedly_open(self._C_con):
+ if _k and _k.is_purportedly_open(self._C_con):
_k.close_connection(self._C_con)
self._C_con = _k.null_connection
elif raiseExceptionOnError:

Regards,
David Hughes

Discussion

  • David S. Rushby

    David S. Rushby - 2004-08-27
    • assigned_to: nobody --> woodsplitter
     
  • David S. Rushby

    David S. Rushby - 2004-08-27

    Logged In: YES
    user_id=414645

    This is odd. Does the problem occur only while the Python
    process is exiting?

    The '_k' referred to in the code above is the C extension
    module that underlies the Python module. For the extension
    module to be None, I would think the system would have to be
    in the process of tearing down the sys.modules container.

    Can you post a program that reproduces this error?

     
  • David Hughes

    David Hughes - 2004-08-31

    Logged In: YES
    user_id=839533

    The problem occurred in several, stand-alone Python scripts
    I was using to populate a database and the .Close() was the
    last line of the script in each case.

    I'll try and produce a minimal program that reproduces this,
    but I'll need to unravel several layers of wrappings first.

     
  • David S. Rushby

    David S. Rushby - 2004-10-03
    • status: open --> open-fixed
     
  • David S. Rushby

    David S. Rushby - 2004-10-03

    Logged In: YES
    user_id=414645

    I'm going to apply your patch to the official code base.

    Previously, I was reluctant to apply it because I didn't
    understand why the problem arose. Oleg Deribas's duplicate
    bug report
    (http://sourceforge.net/tracker/index.php?func=detail&aid=1031132&group_id=9913&atid=109913
    ) contained some crucial information that set off a light
    bulb in my head. I can now imagine a scenario in which _k
    would already have been destroyed prior to the
    _close_physical_connection call.

    Thanks to both David Hughes and Oleg Deribas for their bug
    reports.

     
  • David S. Rushby

    David S. Rushby - 2004-10-25
    • labels: --> General problems
    • status: open-fixed --> closed-fixed
     
  • David S. Rushby

    David S. Rushby - 2004-10-25

    Logged In: YES
    user_id=414645

    Now incorporated into released version 3.1_pre9, so I'm
    closing the bug report.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks