RazerM/sqlalchemy_aio

Problem for closing properly a connection

dhenryFabrice opened this issue · 1 comments

First, I wish you an happy new year 2018,

I randomly get an error if I trigger await conn.close():
" File "C:\Users\dhenry\AppData\Local\Programs\Python\Python36\lib\site-packages\sqlalchemy\engine\default.py", line 463, in do_close
dbapi_connection.close()
sqlite3.OperationalError: unable to close due to unfinalized statements or unfinished backups"

If I do not close the connection I get another error:
File "C:\Users\dhenry\AppData\Local\Programs\Python\Python36\lib\site-packages\sqlalchemy\engine\default.py", line 463, in do_close
dbapi_connection.close()
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 7356 and this is thread id 25704

The code is running under windows 10, python 3.6 in a pytest process.

Best regards,

PS: my first thought was to put the conn.close() in the del method of my class but I could not figure out how to run it in the already running loop.

Hi,

So I found my mistake (nothing to do with your library), sorry for posting this issue.

Many thanks

Best regards