fix(python): run remote SDK futures in background thread (#1856)

Users who call the remote SDK from code that uses futures (either
`ThreadPoolExecutor` or `asyncio`) can get odd errors like:

```
Traceback (most recent call last):
  File "/usr/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
RuntimeError: cannot enter context: <_contextvars.Context object at 0x7cfe94cdc900> is already entered
```

This PR fixes that by executing all LanceDB futures in a dedicated
thread pool running on a background thread. That way, it doesn't
interact with their threadpool.
This commit is contained in:
Will Jones
2024-11-25 13:12:47 -08:00
committed by GitHub
parent 3e9321fc40
commit 6826039575
5 changed files with 92 additions and 47 deletions
-1
View File
@@ -3,7 +3,6 @@ name = "lancedb"
# version in Cargo.toml
dependencies = [
"deprecation",
"nest-asyncio~=1.0",
"pylance==0.20.0b2",
"tqdm>=4.27.0",
"pydantic>=1.10",