Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to delete Connection #40

Open
ant-zuev opened this issue Sep 6, 2024 · 1 comment
Open

Unable to delete Connection #40

ant-zuev opened this issue Sep 6, 2024 · 1 comment

Comments

@ant-zuev
Copy link
Contributor

ant-zuev commented Sep 6, 2024

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
@pcisar
Copy link
Contributor

pcisar commented Oct 1, 2024

What do you mean you cannot delete the Connection object? It's in fact deleted just fine, as the stack trace confirms. The exception is reported for __del__ finalizer, which was called when connection went out of scope (so it never reached the con.close() otherwise it would be reported from there). Also note that this exception is ignored, just reported as it doesn't does not mean anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants