ITPortal.Core
1.2.37
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
<PackageReference Include="ITPortal.Core" Version="1.2.37" />
<PackageVersion Include="ITPortal.Core" Version="1.2.37" />
<PackageReference Include="ITPortal.Core" />
paket add ITPortal.Core --version 1.2.37
#r "nuget: ITPortal.Core, 1.2.37"
#:package ITPortal.Core@1.2.37
#addin nuget:?package=ITPortal.Core&version=1.2.37
#tool nuget:?package=ITPortal.Core&version=1.2.37
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;
新增能力
Python代码执行 await _executor.ExecuteCodeAsync(""" print(True) """);
Python文件执行 await _executor.ExecuteFileAsync( @"D:\scripts\demo.py");
网络脚本执行 await _executor.ExecuteUrlAsync( "https://xxx/demo.py");
bool返回 bool result = await _executor.ExecuteBoolCodeAsync( "print(True)");
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 | Versions 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. |
-
net10.0
- Consul (>= 1.8.0)
- Elastic.Clients.Elasticsearch (>= 8.18.0)
- Furion.Extras.Authentication.JwtBearer (>= 4.9.8.92)
- Furion.Extras.ObjectMapper.Mapster (>= 4.9.8.92)
- Furion.Pure (>= 4.9.8.92)
- ITPortal.Extension (>= 1.2.37)
- MailKit (>= 4.17.0)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 8.0.23)
- Microsoft.AspNetCore.OpenApi (>= 8.0.23)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 9.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.16)
- Microsoft.Extensions.ServiceDiscovery (>= 8.2.2)
- MiniExcel (>= 1.44.1)
- Ocelot (>= 24.1.0)
- RabbitMQ.Client (>= 7.2.1)
- Shapeless (>= 1.2.2)
- SqlSugarCore (>= 5.1.4.214)
- Swashbuckle.AspNetCore.Newtonsoft (>= 8.1.1)
- Winton.Extensions.Configuration.Consul (>= 3.4.0)
-
net8.0
- Consul (>= 1.8.0)
- Elastic.Clients.Elasticsearch (>= 8.18.0)
- Furion.Extras.Authentication.JwtBearer (>= 4.9.8.92)
- Furion.Extras.ObjectMapper.Mapster (>= 4.9.8.92)
- Furion.Pure (>= 4.9.8.92)
- ITPortal.Extension (>= 1.2.37)
- MailKit (>= 4.17.0)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 8.0.23)
- Microsoft.AspNetCore.OpenApi (>= 8.0.23)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 9.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.16)
- Microsoft.Extensions.ServiceDiscovery (>= 8.2.2)
- MiniExcel (>= 1.44.1)
- Ocelot (>= 24.1.0)
- RabbitMQ.Client (>= 7.2.1)
- Shapeless (>= 1.2.2)
- SqlSugarCore (>= 5.1.4.214)
- Swashbuckle.AspNetCore.Newtonsoft (>= 8.1.1)
- Winton.Extensions.Configuration.Consul (>= 3.4.0)
-
net9.0
- Consul (>= 1.8.0)
- Elastic.Clients.Elasticsearch (>= 8.18.0)
- Furion.Extras.Authentication.JwtBearer (>= 4.9.8.92)
- Furion.Extras.ObjectMapper.Mapster (>= 4.9.8.92)
- Furion.Pure (>= 4.9.8.92)
- ITPortal.Extension (>= 1.2.37)
- MailKit (>= 4.17.0)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 8.0.23)
- Microsoft.AspNetCore.OpenApi (>= 8.0.23)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 9.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.16)
- Microsoft.Extensions.ServiceDiscovery (>= 8.2.2)
- MiniExcel (>= 1.44.1)
- Ocelot (>= 24.1.0)
- RabbitMQ.Client (>= 7.2.1)
- Shapeless (>= 1.2.2)
- SqlSugarCore (>= 5.1.4.214)
- Swashbuckle.AspNetCore.Newtonsoft (>= 8.1.1)
- Winton.Extensions.Configuration.Consul (>= 3.4.0)
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 |
初始版本,包含分布式缓存、邮件发送、事件总线、API代理、SQL解析等多个核心功能模块的实现。
v1.2.9,更新furion相关库到最新版本,修复部分已知问题。