-
Notifications
You must be signed in to change notification settings - Fork 10
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
deadlock when using flask and libsql with local db (works fine with stock sqlite3 library) #30
Comments
nvm, the code is must simpler to deadlock: import libsql_client
import sys
import sqlite3
if __name__ == "__main__":
assert sys.argv[1] in ("sqlite3", "libsql"), sys.argv[1]
if sys.argv[1] == "sqlite3":
db = sqlite3.Connection("test.db")
data = db.execute("select item from data").fetchall()[0][0]
else:
db = libsql_client.create_client_sync(f"file:test.db")
data = db.execute("select item from data").rows[0][0]
assert data == "world"
print("AAAAAAAAAAAAAAA") It hangs here: async def _dequeue_item(self) -> Optional[_QueueItem]:
while True:
with self._lock:
print("locked _deque_item")
if len(self._queue) > 0:
return self._queue.popleft()
assert self._waker is None
waker = self._loop.create_future()
self._waker = waker
print("before await waker")
await waker # < this never ends
print("unlocked _deque_item")
I feel like I'm using the library wrong, i expected just to find & replace my |
seems that using https:/tursodatabase/libsql-experimental-python/ (as per https://docs.turso.tech/sdk/python/quickstart#local-only) provides a much closer API to the stock sqlite3 library and doesn't deadlock. I guess I'll use that but it's a bit confusing to have two of them. Why not semver and use the same repo? I got a bit confused for sure. |
minimal repro i could come up with. Tested on python 3.11 (created via
conda create -n deadlock python=3.11 anaconda
)run via:
python main.py [sqlite3/libsql]
Versions:
Upon ctrl+c:
The text was updated successfully, but these errors were encountered: