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

ArbitraryFileIdManager writes to SQLite database when garbage collected #75

Closed
davidbrochart opened this issue Apr 8, 2024 · 0 comments · Fixed by #81
Closed

ArbitraryFileIdManager writes to SQLite database when garbage collected #75

davidbrochart opened this issue Apr 8, 2024 · 0 comments · Fixed by #81
Labels
bug Something isn't working

Comments

@davidbrochart
Copy link
Contributor

Description

The ArbitraryFileIdManager does some cleanup in its __del__ method here, which involves writing to a SQLite database.
This creates issues in tests (for example here):

E   pytest.PytestUnraisableExceptionWarning: Exception ignored in: <function ArbitraryFileIdManager.__del__ at 0x7fa08739f920>
E   
E   Traceback (most recent call last):
E     File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/jupyter_server_fileid/manager.py", line 391, in __del__
E       self.con.commit()
E   sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 1403275078[56](https://github.com/jupyterlab/jupyter-collaboration/actions/runs/8603265131/job/23574762141?pr=279#step:6:57)256 and this is thread id 140327414023744.

In general, I don't think it is a good practice because the object can be garbage-collected from a different thread that the one in which it was created.
A better solution would be to do this in the teardown of the extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant