home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 643685669

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/datasette/issues/846#issuecomment-643685669 https://api.github.com/repos/simonw/datasette/issues/846 643685669 MDEyOklzc3VlQ29tbWVudDY0MzY4NTY2OQ== 9599 2020-06-13T22:24:22Z 2020-06-13T22:24:22Z OWNER

I tried this experiment: python import sqlite3, psutil def show_things(): conn = sqlite3.connect("fixtures.db") tables = [r[0] for r in conn.execute("select * from sqlite_master").fetchall()] return tables print(psutil.Process().open_files()) print(show_things()) print(psutil.Process().open_files()) To see if the connection would be automatically released when the conn variable was garbage collected at the end of the function... and it was correctly released - the two calls to open_files() showed that the file did not remain open.

Likewise: ``` In [11]: conn = sqlite3.connect("fixtures.db")

In [12]: psutil.Process().open_files()
Out[12]: [popenfile(path='/Users/simon/.ipython/profile_default/history.sqlite', fd=4), popenfile(path='/Users/simon/.ipython/profile_default/history.sqlite', fd=5), popenfile(path='/Users/simon/Dropbox/Development/datasette/fixtures.db', fd=12)]

In [13]: del conn

In [14]: psutil.Process().open_files()
Out[14]: [popenfile(path='/Users/simon/.ipython/profile_default/history.sqlite', fd=4), popenfile(path='/Users/simon/.ipython/profile_default/history.sqlite', fd=5)] `` So presumably there's something about the way my pytest fixtures work that's causing the many differentDatasette()` instances and their underlying SQLite connections that I create not to be cleaned up later.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
638241779  
Powered by Datasette · Queries took 0.984ms · About: github-to-sqlite