- Notifications
You must be signed in to change notification settings - Fork328
Added once_cell crate to make RUNTIME lazy#1386
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -44,6 +44,7 @@ colored = "2" | ||
ctrlc = "3" | ||
inquire = "0.6" | ||
parking_lot = "0.12.1" | ||
once_cell = "1.19.0" | ||
[features] | ||
default = [] | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,6 +4,7 @@ | ||
//! | ||
//! With this SDK, you can seamlessly manage various database tables related to documents, text chunks, text splitters, LLM (Language Model) models, and embeddings. By leveraging the SDK's capabilities, you can efficiently index LLM embeddings using PgVector for fast and accurate queries. | ||
use once_cell::sync::Lazy; | ||
use parking_lot::RwLock; | ||
use sqlx::{postgres::PgPoolOptions, PgPool}; | ||
use std::collections::HashMap; | ||
@@ -123,24 +124,15 @@ fn internal_init_logger(level: Option<String>, format: Option<String>) -> anyhow | ||
// Normally the global async runtime is handled by tokio but because we are a library being called | ||
// by javascript and other langauges, we occasionally need to handle it ourselves | ||
static RUNTIME: Lazy<Runtime> = Lazy::new(|| { | ||
Builder::new_multi_thread() | ||
.enable_all() | ||
.build() | ||
.expect("Error creating tokio runtime") | ||
}); | ||
fn get_or_set_runtime<'a>() -> &'a Runtime { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Oh wow, makes sense. This is totally not thread safe! | ||
&RUNTIME | ||
} | ||
#[cfg(feature = "python")] | ||