Open mehdibn opened 1 year ago
Hi,
I reproduced the problem with a call to /api/v1/plan/reconfigure (an async endpoint). The problem does not occur with sync endpoint. When there is nothing to restart, the server is supposed to answer a HTTP 400 status. But instead, a HTTP 500 is sent. This HTTP 500 is caused by the exception listed below :
File "/home/diode-ben-aissa01/dev/tdp-lib/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 683, in do_rollback dbapi_connection.rollback() sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140652912154432 and this is thread id 140651983267584.
The server tried to rollback the transaction but couldn't because the SQL session is not in the same thread. One correction could be to close the session after each request.
Here is the discussion from the PR #121 :
db.close()
must not be used {'check_same_thread': False}
is specific to SQLite.I will close the PR and delete the branch.
After reconfigure action, this error was generated (
SQLite objects created in a thread can only be used in that same thread.
):