diff --git a/jupyter_server_fileid/manager.py b/jupyter_server_fileid/manager.py index 30d7170..e19f204 100644 --- a/jupyter_server_fileid/manager.py +++ b/jupyter_server_fileid/manager.py @@ -386,8 +386,14 @@ def __del__(self): """Cleans up `ArbitraryFileIdManager` by committing any pending transactions and closing the connection.""" if hasattr(self, "con"): - self.con.commit() - self.con.close() + # If garbage collection happens in a different thread than the thread where + # the SQLite object was created, committing will fail anyway. We just ignore + # the exception if this is the case. + try: + self.con.commit() + self.con.close() + except sqlite3.ProgrammingError: + pass class LocalFileIdManager(BaseFileIdManager):