File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed
BotSharp.Abstraction/CodeInterpreter/Models
BotSharp.Core/data/agents/01e2fc5c-2c89-4ec7-8470-7688608b496c/codes/src
Plugins/BotSharp.Plugin.PythonInterpreter/Services Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -6,5 +6,6 @@ public class CodeInterpretOptions
66{
77 public string ? ScriptName { get ; set ; }
88 public IEnumerable < KeyValue > ? Arguments { get ; set ; }
9+ public bool UseMutex { get ; set ; }
910 public CancellationToken ? CancellationToken { get ; set ; }
1011}
Original file line number Diff line number Diff line change 11import argparse
2+ import json
23
34def main ():
45 parser = argparse .ArgumentParser (description = "Receive named arguments" )
56 parser .add_argument ("--first_name" , required = True , help = "The first name" )
67 parser .add_argument ("--last_name" , required = True , help = "The last name" )
78
8- args = parser .parse_args ()
9- print (f"Hello, { args .first_name } { args .last_name } !" )
9+ args , _ = parser .parse_known_args ()
10+ obj = {
11+ "first_name" : args .first_name ,
12+ "last_name" :args .last_name
13+ }
14+ print (f"{ json .dumps (obj )} " )
1015
1116if __name__ == "__main__" :
1217 main ()
Original file line number Diff line number Diff line change 11using BotSharp . Core . CodeInterpreter ;
22using Microsoft . Extensions . Logging ;
33using Python . Runtime ;
4+ using System . Threading ;
45using System . Threading . Tasks ;
56
67namespace BotSharp . Plugin . PythonInterpreter . Services ;
@@ -25,6 +26,13 @@ public PyInterpretService(
2526
2627 public async Task < CodeInterpretResult > RunCode ( string codeScript , CodeInterpretOptions ? options = null )
2728 {
29+ if ( options ? . UseMutex == true )
30+ {
31+ return await _executor . Execute ( async ( ) =>
32+ {
33+ return InnerRunCode ( codeScript , options ) ;
34+ } , cancellationToken : options ? . CancellationToken ?? CancellationToken . None ) ;
35+ }
2836 return InnerRunCode ( codeScript , options ) ;
2937 }
3038
You can’t perform that action at this time.
0 commit comments