File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed
Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ mod snapshot;
1313mod version_check;
1414
1515use std:: future:: Future ;
16+ use std:: thread;
1617
1718use tonic:: codegen:: InterceptedService ;
1819use tonic:: transport:: { Channel , Uri } ;
@@ -108,16 +109,21 @@ impl Qdrant {
108109 let client = Self { channel, config } ;
109110
110111 if check_compatibility {
111- let health_check_future = client. health_check ( ) ;
112-
113- // Run future on current or new runtime depending on current context
114- let server_version = match tokio:: runtime:: Handle :: try_current ( ) {
115- Ok ( _) => futures:: executor:: block_on ( health_check_future) ,
116- Err ( _) => tokio:: runtime:: Runtime :: new ( )
117- . unwrap ( )
118- . block_on ( health_check_future) ,
119- } ;
120- let server_version = server_version. map ( |info| info. version ) . ok ( ) ;
112+ // We're in sync context, spawn temporary runtime in thread to do async health check
113+ let server_version = thread:: scope ( |s| {
114+ s. spawn ( || {
115+ tokio:: runtime:: Builder :: new_current_thread ( )
116+ . enable_io ( )
117+ . enable_time ( )
118+ . build ( )
119+ . map_err ( QdrantError :: Io ) ?
120+ . block_on ( client. health_check ( ) )
121+ } )
122+ . join ( )
123+ . unwrap ( )
124+ } )
125+ . ok ( )
126+ . map ( |info| info. version ) ;
121127
122128 let client_version = env ! ( "CARGO_PKG_VERSION" ) . to_string ( ) ;
123129 if let Some ( server_version) = server_version {
You can’t perform that action at this time.
0 commit comments