python3-driver icon indicating copy to clipboard operation
python3-driver copied to clipboard

Unable to delete Connection

Open ant-zuev opened this issue 1 year ago • 0 comments

When a connection is lost, for example as a result of a server shutdown, after several attempts to execute statements, we cannot delete the Connection object. Reproduced with an uncommitted cursor transaction.

from firebird.driver import connect
import os

con = connect('localhost:employee', user='sysdba', password='masterkey')

cur = con.cursor()
cur.execute("select 1 from rdb$database")

os.system('pkill firebird')

con.execute_immediate("insert into test values(1)")
con.execute_immediate("insert into test values(1)")

try:
    con.close()
except Exception:
    pass

exit()

The object is not deleted and on exit we get an exception to delete the cursor and statement:

Exception ignored in: <function Cursor.__del__ at 0x716f1160f2e0>
Traceback (most recent call last):
  File "env/lib/python3.12/site-packages/firebird/driver/core.py", line 3047, in __del__
  File "env/lib/python3.12/site-packages/firebird/driver/core.py", line 3791, in close
  File "env/lib/python3.12/site-packages/firebird/driver/core.py", line 2736, in free
  File "env/lib/python3.12/site-packages/firebird/driver/interfaces.py", line 832, in free
  File "env/lib/python3.12/site-packages/firebird/driver/interfaces.py", line 113, in _check
firebird.driver.types.DatabaseError: connection shutdown
Exception ignored in: <function Statement.__del__ at 0x716f1160d940>
Traceback (most recent call last):
  File "env/lib/python3.12/site-packages/firebird/driver/core.py", line 2712, in __del__
  File "env/lib/python3.12/site-packages/firebird/driver/core.py", line 2736, in free
  File "env/lib/python3.12/site-packages/firebird/driver/interfaces.py", line 832, in free
  File "env/lib/python3.12/site-packages/firebird/driver/interfaces.py", line 113, in _check
firebird.driver.types.DatabaseError: connection shutdown

ant-zuev avatar Sep 06 '24 06:09 ant-zuev