@@ -149,6 +149,9 @@ struct PyFunctionExecutor {
149149 num_positional_args : usize ,
150150 kw_args_names : Vec < Py < PyString > > ,
151151 result_type : schema:: EnrichedValueType ,
152+
153+ enable_cache : bool ,
154+ behavior_version : Option < u32 > ,
152155}
153156
154157#[ async_trait]
@@ -193,6 +196,14 @@ impl SimpleFunctionExecutor for Arc<PyFunctionExecutor> {
193196 } )
194197 . await
195198 }
199+
200+ fn enable_cache ( & self ) -> bool {
201+ self . enable_cache
202+ }
203+
204+ fn behavior_version ( & self ) -> Option < u32 > {
205+ self . behavior_version
206+ }
196207}
197208
198209pub ( crate ) struct PyFunctionFactory {
@@ -251,15 +262,27 @@ impl SimpleFunctionFactory for PyFunctionFactory {
251262
252263 let executor_fut = {
253264 let result_type = result_type. clone ( ) ;
254- async move {
255- Python :: with_gil ( |py| executor. call_method ( py, "prepare" , ( ) , None ) ) ?;
265+ unblock ( move || {
266+ let ( enable_cache, behavior_version) =
267+ Python :: with_gil ( |py| -> anyhow:: Result < _ > {
268+ executor. call_method ( py, "prepare" , ( ) , None ) ?;
269+ let enable_cache = executor
270+ . call_method ( py, "enable_cache" , ( ) , None ) ?
271+ . extract :: < bool > ( py) ?;
272+ let behavior_version = executor
273+ . call_method ( py, "behavior_version" , ( ) , None ) ?
274+ . extract :: < Option < u32 > > ( py) ?;
275+ Ok ( ( enable_cache, behavior_version) )
276+ } ) ?;
256277 Ok ( Box :: new ( Arc :: new ( PyFunctionExecutor {
257278 py_function_executor : executor,
258279 num_positional_args,
259280 kw_args_names,
260281 result_type,
282+ enable_cache,
283+ behavior_version,
261284 } ) ) as Box < dyn SimpleFunctionExecutor > )
262- }
285+ } )
263286 } ;
264287
265288 Ok ( ( result_type, executor_fut. boxed ( ) ) )
0 commit comments