ITPortal.Core 1.2.37

There is a newer version of this package available.
See the version list below for details.
dotnet add package ITPortal.Core --version 1.2.37
                    
NuGet\Install-Package ITPortal.Core -Version 1.2.37
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ITPortal.Core" Version="1.2.37" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ITPortal.Core" Version="1.2.37" />
                    
Directory.Packages.props
<PackageReference Include="ITPortal.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ITPortal.Core --version 1.2.37
                    
#r "nuget: ITPortal.Core, 1.2.37"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ITPortal.Core@1.2.37
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ITPortal.Core&version=1.2.37
                    
Install as a Cake Addin
#tool nuget:?package=ITPortal.Core&version=1.2.37
                    
Install as a Cake Tool

PythonExecutor 升级说明 版本升级

本次升级属于增强版生产级改造,涉及接口、依赖注入、并发控制、超时处理和后台清理机制。

新增依赖包

配置文件变更

新增:

{ "PythonExecutor": { "PythonPath": "/usr/bin/python3", "MaxConcurrentExecutions": 10, "MaxConcurrentPerKey": 2, "MaxOutputLength": 1048576, "DefaultTimeout": "00:05:00", "WorkRoot": "/tmp/python-runner", "MaxScriptBytes": 5242880 } }

Windows:

{ "PythonExecutor": { "PythonPath": "C:\Python312\python.exe" } }

Linux:

{ "PythonExecutor": { "PythonPath": "/usr/bin/python3" } }

DI注册方式变更 旧版本 services.AddSingleton( new PythonExecutor( new PythonExecutorOptions { PythonPath = "python" }));

新版本 services.Configure<PythonExecutorOptions>( configuration.GetSection("PythonExecutor"));

services.AddHttpClient();

services.AddSingleton< IPythonExecutor, PythonExecutor>();

services.AddHostedService< PythonExecutorCleanupService>();

推荐通过接口注入:

private readonly IPythonExecutor _pythonExecutor;

public DemoService( IPythonExecutor pythonExecutor) { _pythonExecutor = pythonExecutor; }

接口变更

新增:

IPythonExecutor

旧代码:

private readonly PythonExecutor _executor;

改为:

private readonly IPythonExecutor _executor;

新增能力

  1. Python代码执行 await _executor.ExecuteCodeAsync(""" print(True) """);

  2. Python文件执行 await _executor.ExecuteFileAsync( @"D:\scripts\demo.py");

  3. 网络脚本执行 await _executor.ExecuteUrlAsync( "https://xxx/demo.py");

  4. bool返回 bool result = await _executor.ExecuteBoolCodeAsync( "print(True)");

  5. Health Check var health = await _executor.GetHealthAsync();

Console.WriteLine( health.Version);

行为变更 Python启动参数

新增:

python -u

关闭输出缓冲。

避免:

print("hello") time.sleep(100)

日志长时间不返回。

工作目录隔离

旧版本:

/tmp

共享目录。

新版本:

/tmp/python-runner ├── job-a ├── job-b └── job-c

每次执行独立目录。

超时机制

新增:

timeout: TimeSpan.FromMinutes(5)

使用:

await _executor.ExecuteCodeAsync( code, timeout: TimeSpan.FromSeconds(10));

超时后:

result.IsTimeout == true

取消机制

新增:

CancellationToken

使用:

using var cts = new CancellationTokenSource();

cts.CancelAfter(1000);

await _executor.ExecuteCodeAsync( code, cancellationToken: cts.Token);

取消后:

result.IsCancelled == true

输出限制

新增:

MaxOutputLength

防止:

while True: print("AAAA")

导致内存溢出。

结果:

result.OutputTruncated

可判断是否被截断。

并发控制

新增:

MaxConcurrentExecutions

全局最大并发。

例如:

{ "MaxConcurrentExecutions": 10 }

全局最多10个Python任务同时运行。

新增:

MaxConcurrentPerKey

单租户限流。

例如:

await _executor.ExecuteCodeAsync( code, executeKey: $"tenant-{tenantId}");

配置:

{ "MaxConcurrentPerKey": 2 }

同一个租户最多2个任务同时运行。

后台服务

新增:

PythonExecutorCleanupService

作用:

自动清理长期未访问的 Semaphore 避免 Key 无限增长 防止内存泄漏

默认:

每30分钟执行一次

无需手工调用。

日志

新增:

ILogger<PythonExecutor>

自动记录:

执行开始 执行结束 耗时 退出码 超时 取消 异常

示例:

Python execution started. Key=tenant-1001

Python execution finished. ExitCode=0 Duration=1200ms

Python execution timeout. Key=tenant-1001

测试代码变更 FluentAssertions 8+

旧写法:

result.BoolResult.Should().BeTrue();

可能编译失败。

改为:

result.BoolResult.Should().Be(true);

或者:

result.BoolResult!.Value.Should().BeTrue();

已验证场景

已覆盖:

✓ Windows ✓ Linux ✓ Docker ✓ Python文件执行 ✓ Python字符串执行 ✓ URL脚本执行 ✓ Timeout ✓ CancellationToken ✓ Global Semaphore ✓ Key Semaphore ✓ Output Limit ✓ Process Kill Tree ✓ Health Check ✓ Background Cleanup ✓ xUnit ✓ FluentAssertions

这份说明可以直接作为项目升级文档提交到仓库。

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.29 0 9/3/2026
1.3.28 0 9/3/2026
1.3.27 0 9/3/2026
1.3.26 0 9/3/2026
1.3.25 0 9/3/2026
1.3.24 122 9/2/2026
1.3.23 52 9/2/2026
1.3.22 51 9/2/2026
1.3.21 60 9/2/2026
1.3.20 67 9/1/2026
1.3.19 70 9/1/2026
1.2.38 0 9/3/2026
1.2.37 0 9/3/2026
1.2.36 0 9/3/2026
1.2.35 0 9/3/2026
1.2.34 0 9/3/2026
1.2.32 52 9/2/2026
1.2.31 50 9/2/2026
1.2.30 51 9/2/2026
1.2.29 73 9/1/2026
Loading failed

初始版本,包含分布式缓存、邮件发送、事件总线、API代理、SQL解析等多个核心功能模块的实现。
     v1.2.9,更新furion相关库到最新版本,修复部分已知问题。