From 6558d0818c98fc8fd784d35a5c87690b6899895f Mon Sep 17 00:00:00 2001 From: foefl Date: Wed, 30 Apr 2025 11:22:16 +0200 Subject: [PATCH] option to indicate running in threaded env, related to #13 --- dopt.DeltaBarth.Tests/PluginTest.cs | 15 +++++++++++++++ dopt.DeltaBarth/Plugin.cs | 2 +- dopt.DeltaBarth/dopt.DeltaBarth.csproj | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dopt.DeltaBarth.Tests/PluginTest.cs b/dopt.DeltaBarth.Tests/PluginTest.cs index f28e047..614e7ce 100644 --- a/dopt.DeltaBarth.Tests/PluginTest.cs +++ b/dopt.DeltaBarth.Tests/PluginTest.cs @@ -252,5 +252,20 @@ namespace dopt.DeltaBarth.Tests Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code); test.Dispose(); } + [TestMethod] + public void Umsatzprognose_WithoutCompanyIdWithValidDate_Test_DoubleDispose() + { + var test = new TPlugin(); + string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + var date = new DateTime(2015, 1, 1, 12, 45, 30); + var res = test.Umsatzprognose(null, date); + PrettyPrint(res); + Assert.AreEqual(1, res.status.code); + Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code); + test.Dispose(); + test.Dispose(); + Console.WriteLine("After double dispose"); + } } } diff --git a/dopt.DeltaBarth/Plugin.cs b/dopt.DeltaBarth/Plugin.cs index e1e8bf5..42682a5 100644 --- a/dopt.DeltaBarth/Plugin.cs +++ b/dopt.DeltaBarth/Plugin.cs @@ -93,7 +93,7 @@ namespace dopt.DeltaBarth /// /// Der Pfad zur Python-Runtime. Dieser muss zu dem Ordner zeigen, /// in welchem die Runtime in Form eines Ordners mit dem Namen "python" abliegt. - public Plugin(string runtimePath) : base(SharpPython.PyOptimLevels.O, runtimePath: runtimePath, verbose: false) + public Plugin(string runtimePath) : base(SharpPython.PyOptimLevels.O, threaded: true, runtimePath: runtimePath, verbose: false) { base.Initialise(); using (Py.GIL()) diff --git a/dopt.DeltaBarth/dopt.DeltaBarth.csproj b/dopt.DeltaBarth/dopt.DeltaBarth.csproj index 77bb443..d7dab4e 100644 --- a/dopt.DeltaBarth/dopt.DeltaBarth.csproj +++ b/dopt.DeltaBarth/dopt.DeltaBarth.csproj @@ -11,7 +11,7 @@ - +