revert
This commit is contained in:
parent
2079ba3760
commit
333807ceb7
|
|
@ -6,5 +6,6 @@ public class CodeInterpretOptions
|
|||
{
|
||||
public string? ScriptName { get; set; }
|
||||
public IEnumerable<KeyValue>? Arguments { get; set; }
|
||||
public bool UseMutex { get; set; }
|
||||
public CancellationToken? CancellationToken { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
import argparse
|
||||
import json
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Receive named arguments")
|
||||
parser.add_argument("--first_name", required=True, help="The first name")
|
||||
parser.add_argument("--last_name", required=True, help="The last name")
|
||||
|
||||
args = parser.parse_args()
|
||||
print(f"Hello, {args.first_name} {args.last_name}!")
|
||||
args, _ = parser.parse_known_args()
|
||||
obj = {
|
||||
"first_name": args.first_name,
|
||||
"last_name":args.last_name
|
||||
}
|
||||
print(f"{json.dumps(obj)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using BotSharp.Core.CodeInterpreter;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Python.Runtime;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BotSharp.Plugin.PythonInterpreter.Services;
|
||||
|
|
@ -25,6 +26,13 @@ public class PyInterpretService : ICodeInterpretService
|
|||
|
||||
public async Task<CodeInterpretResult> RunCode(string codeScript, CodeInterpretOptions? options = null)
|
||||
{
|
||||
if (options?.UseMutex == true)
|
||||
{
|
||||
return await _executor.Execute(async () =>
|
||||
{
|
||||
return InnerRunCode(codeScript, options);
|
||||
}, cancellationToken: options?.CancellationToken ?? CancellationToken.None);
|
||||
}
|
||||
return InnerRunCode(codeScript, options);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue