SQLite database sessions are not closed
Created by: siebenkopf
Alright, we tracked down the errors that occurs during the nose(xbob) tests on MacOS. The problem seems to be that the SQLite session obtained by:
session = bob.db.utils.session_try_readonly('sqlite', sqlite_file)
is never closed, which means that a file handle to the .sql3 file is opened throughout the complete python session.
Now, the xbob.db .aggregator tests calls bob_dbmanage.py to obtain the database API. During this call, the DB manager iterates over all databases and add their sub-parsers, for each API test that is executed. During the sub-parser call, the SQLite-based databases opens a database connection via the blamed method (see above). This means that for each API test of each database, each SQLite-based database opens a file connection to its .sql3 file.
OK. So far so bad. The problem is that I don't know, how to close this file handle. A simple
doesn't help, and also
is without effect.
This issue exists both for Linux as well as for OSX. We detected it only since in OSX, there is a limited number of file connections that are allowed to be opened at the same time. This explains the test errors.
Sorry, but I gave up on solving this issue. I don't know if anyone with more insight into sqlalchemy might have a better chance of solving the issue.