I am writing my first SQLAlchemy (0.6.8) / Python (2.7.1) program, sitting on top of SQLite (3.7.6.3, I think), running on Windows Vista.
To do unit testing, I point SQLite to the test database, and my unit test scripts usually delete the database file, so I constantly work with the known initial state.
Sometimes my (single-threaded) unit-tests cannot delete a file:
WindowsError: [Error 32] The process cannot access the file because it is being used by another process
The only process using this file is the unit-test wiring harness. Obviously, some locks are not released by one of my completed unit tests, which prevents the removal of the next block in the same process from the file.
I looked at all the places that the session created and confirmed that the corresponding session.commit () or session.rollback () exists.
I looked for all calls to session.commit () and session.rollback () in my code and immediately added a call to session.close () to explicitly release any transactional locks, but hasn’t helped.
Are there any secrets so that the remaining locks are removed at the end of the transaction to allow file deletion?
source share