@@ -82,38 +82,41 @@ impl RefreshResult {
82
82
pub fn handle_refresh ( context : Arc < Context > , id : u32 , params : Value ) {
83
83
match serde_json:: from_value :: < RequestOptions > ( params. clone ( ) ) {
84
84
Ok ( request_options) => {
85
- let mut cfg = context. configuration . write ( ) . unwrap ( ) ;
86
- cfg. search_paths = request_options. search_paths ;
87
- cfg. conda_executable = request_options. conda_executable ;
88
- drop ( cfg) ;
89
- let config = context. configuration . read ( ) . unwrap ( ) . clone ( ) ;
90
- for locator in context. locators . iter ( ) {
91
- locator. configure ( & config) ;
92
- }
93
- let summary = find_and_report_envs (
94
- context. reporter . as_ref ( ) ,
95
- config,
96
- & context. locators ,
97
- context. conda_locator . clone ( ) ,
98
- ) ;
99
- let summary = summary. lock ( ) . unwrap ( ) ;
100
- for locator in summary. find_locators_times . iter ( ) {
101
- info ! ( "Locator {} took {:?}" , locator. 0 , locator. 1 ) ;
102
- }
103
- info ! (
104
- "Environments found using locators in {:?}" ,
105
- summary. find_locators_time
106
- ) ;
107
- info ! ( "Environments in PATH found in {:?}" , summary. find_path_time) ;
108
- info ! (
109
- "Environments in global virtual env paths found in {:?}" ,
110
- summary. find_global_virtual_envs_time
111
- ) ;
112
- info ! (
113
- "Environments in custom search paths found in {:?}" ,
114
- summary. find_search_paths_time
115
- ) ;
116
- send_reply ( id, Some ( RefreshResult :: new ( summary. time ) ) ) ;
85
+ // Start in a new thread, we can have multiple requests.
86
+ thread:: spawn ( move || {
87
+ let mut cfg = context. configuration . write ( ) . unwrap ( ) ;
88
+ cfg. search_paths = request_options. search_paths ;
89
+ cfg. conda_executable = request_options. conda_executable ;
90
+ drop ( cfg) ;
91
+ let config = context. configuration . read ( ) . unwrap ( ) . clone ( ) ;
92
+ for locator in context. locators . iter ( ) {
93
+ locator. configure ( & config) ;
94
+ }
95
+ let summary = find_and_report_envs (
96
+ context. reporter . as_ref ( ) ,
97
+ config,
98
+ & context. locators ,
99
+ context. conda_locator . clone ( ) ,
100
+ ) ;
101
+ let summary = summary. lock ( ) . unwrap ( ) ;
102
+ for locator in summary. find_locators_times . iter ( ) {
103
+ info ! ( "Locator {} took {:?}" , locator. 0 , locator. 1 ) ;
104
+ }
105
+ info ! (
106
+ "Environments found using locators in {:?}" ,
107
+ summary. find_locators_time
108
+ ) ;
109
+ info ! ( "Environments in PATH found in {:?}" , summary. find_path_time) ;
110
+ info ! (
111
+ "Environments in global virtual env paths found in {:?}" ,
112
+ summary. find_global_virtual_envs_time
113
+ ) ;
114
+ info ! (
115
+ "Environments in custom search paths found in {:?}" ,
116
+ summary. find_search_paths_time
117
+ ) ;
118
+ send_reply ( id, Some ( RefreshResult :: new ( summary. time ) ) ) ;
119
+ } ) ;
117
120
}
118
121
Err ( e) => {
119
122
send_reply ( id, None :: < u128 > ) ;
0 commit comments