shell-history icon indicating copy to clipboard operation
shell-history copied to clipboard

SQLite objects created in a thread can only be used in that same thread

Open sirfoga opened this issue 5 years ago • 4 comments

my system

$ uname -a Linux novo 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

$ zsh --version zsh 5.4.2 (x86_64-ubuntu-linux-gnu)

my problem

when I open a the admin page I get a 500 error due to SQLite objects created in a thread can only be used in that same thread.

solution

add a get_session like to db.py

Session = sessionmaker(bind=engine)

def get_session():
    _engine = create_engine("sqlite:///%s" % DB_PATH)
    session = sessionmaker(bind=_engine)
    return session()

in order to create a new SQLite session (that will be destroyed)

my solution

this PR

@pawamoy thanks for your work

Boost priority

  • Boost priority in our backlog through Polar.sh. Higher pledge, higher priority.
  • Minimum pledge by user/organization is $5, minimum amount for boost is $30.
  • View all issues with pledges.
  • We receive the funds once the issue is completed and confirmed by you.
  • Features with the insiders label are released to sponsors first, and tied to a funding goal.
Fund with Polar

sirfoga avatar Apr 13 '19 12:04 sirfoga

Hi @sirfoga, thank you very much for your reports and PRs!! I'll have time to look at them tomorrow!

pawamoy avatar Apr 13 '19 14:04 pawamoy

Closed by https://github.com/pawamoy/shell-history/commit/a699eac45d5b38b275b65721f20b254433e10499

pawamoy avatar Apr 14 '19 16:04 pawamoy

In fact it still happens. I don't understand what we're doing wrong. We might as well refactor using Django instead of Flask...

pawamoy avatar May 17 '19 14:05 pawamoy

use of scoped_session (see this SO answer) ?

sirfoga avatar May 18 '19 06:05 sirfoga