Skip to content

Commit 2b9dcd1

Browse files
authored
docs: Clarify thread safety (#219)
1 parent e2ff727 commit 2b9dcd1

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Optional parameters
2929
## Examples
3030
See [PEP-249](https://www.python.org/dev/peps/pep-0249) for the DB API reference and specifications. An example [jupyter notebook](https://github.com/firebolt-db/firebolt-sdk/tree/main/examples/dbapi.ipynb) is included to illustrate the use of the Firebolt API.
3131

32+
## Special considerations
33+
### Cursor objects should not be shared between threads
34+
Cursor is not thread-safe and should not be shared across threads. In a multi-threaded environment you can share a Connection, but each thread would need to keep its own Cursor. This corresponds to a thread safety 2 in the [DBApi specification](https://peps.python.org/pep-0249/#threadsafety).
35+
3236
## Optional features
3337
### Faster datetime with ciso8601
3438
By default, firebolt-sdk uses `datetime` module to parse date and datetime values, which might be slow for a large amount of operations. In order to speed up datetime operations, it's possible to use [ciso8601](https://pypi.org/project/ciso8601/) package. In order to install firebolt-sdk with `ciso8601` support, run `pip install "firebolt-sdk[ciso8601]"`

src/firebolt/async_db/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232

3333
apilevel = "2.0"
3434
# threads may only share the module and connections, cursors should not be shared
35-
threadsafety = 1
35+
threadsafety = 2
3636
paramstyle = "qmark"

src/firebolt/db/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
)
3232

3333
apilevel = "2.0"
34-
threadsafety = 3 # threads may share the module, connections and cursors
34+
# threads may only share the module and connections, cursors should not be shared
35+
threadsafety = 2
3536
paramstyle = "qmark"

0 commit comments

Comments
 (0)