@@ -30,17 +30,17 @@ public PyCodeInterpreter(
3030
3131 public string Provider => "botsharp-py-interpreter" ;
3232
33- public async Task < CodeInterpretResponse > RunAsync ( string codeScript , CodeInterpretOptions ? options = null )
33+ public async Task < CodeInterpretResponse > RunAsync ( string codeScript , CodeInterpretOptions ? options = null , CancellationToken ? cancellationToken = null )
3434 {
3535 if ( options ? . UseLock == true )
3636 {
3737 return await _executor . ExecuteAsync ( async ( ) =>
3838 {
39- return await InnerRunCode ( codeScript , options ) ;
40- } , cancellationToken : options ? . LockToken ?? CancellationToken . None ) ;
39+ return await InnerRunCode ( codeScript , options , cancellationToken ) ;
40+ } , cancellationToken : cancellationToken ?? CancellationToken . None ) ;
4141 }
4242
43- return await InnerRunCode ( codeScript , options ) ;
43+ return await InnerRunCode ( codeScript , options , cancellationToken ) ;
4444 }
4545
4646 public async Task < CodeGenerationResult > GenerateCodeScriptAsync ( string text , CodeGenerationOptions ? options = null )
@@ -98,7 +98,7 @@ public async Task<CodeGenerationResult> GenerateCodeScriptAsync(string text, Cod
9898
9999
100100 #region Private methods
101- private async Task < CodeInterpretResponse > InnerRunCode ( string codeScript , CodeInterpretOptions ? options = null )
101+ private async Task < CodeInterpretResponse > InnerRunCode ( string codeScript , CodeInterpretOptions ? options = null , CancellationToken ? cancellationToken = null )
102102 {
103103 var response = new CodeInterpretResponse ( ) ;
104104 var scriptName = options ? . ScriptName ?? codeScript . SubstringMax ( 30 ) ;
@@ -109,11 +109,11 @@ private async Task<CodeInterpretResponse> InnerRunCode(string codeScript, CodeIn
109109
110110 if ( options ? . UseProcess == true )
111111 {
112- response = await CoreRunProcess ( codeScript , options ) ;
112+ response = await CoreRunProcess ( codeScript , options , cancellationToken ) ;
113113 }
114114 else
115115 {
116- response = await CoreRunScript ( codeScript , options ) ;
116+ response = await CoreRunScript ( codeScript , options , cancellationToken ) ;
117117 }
118118
119119 _logger . LogWarning ( $ "End running python code script in { Provider } : { scriptName } ") ;
@@ -134,11 +134,11 @@ private async Task<CodeInterpretResponse> InnerRunCode(string codeScript, CodeIn
134134 }
135135 }
136136
137- private async Task < CodeInterpretResponse > CoreRunScript ( string codeScript , CodeInterpretOptions ? options = null )
137+ private async Task < CodeInterpretResponse > CoreRunScript ( string codeScript , CodeInterpretOptions ? options = null , CancellationToken ? cancellationToken = null )
138138 {
139139 _logger . LogWarning ( $ "Begin { nameof ( CoreRunScript ) } in { Provider } : ${ options ? . ScriptName } ") ;
140140
141- var token = options ? . OperationToken ?? CancellationToken . None ;
141+ var token = cancellationToken ?? CancellationToken . None ;
142142 token . ThrowIfCancellationRequested ( ) ;
143143
144144 using ( Py . GIL ( ) )
@@ -210,9 +210,9 @@ private async Task<CodeInterpretResponse> CoreRunScript(string codeScript, CodeI
210210 }
211211
212212
213- private async Task < CodeInterpretResponse > CoreRunProcess ( string codeScript , CodeInterpretOptions ? options = null )
213+ private async Task < CodeInterpretResponse > CoreRunProcess ( string codeScript , CodeInterpretOptions ? options = null , CancellationToken ? cancellationToken = null )
214214 {
215- var token = options ? . OperationToken ?? CancellationToken . None ;
215+ var token = cancellationToken ?? CancellationToken . None ;
216216
217217 var psi = new ProcessStartInfo
218218 {
0 commit comments