From 5ee3098ac0647054283a8df11ed4ffe4bc335a2b Mon Sep 17 00:00:00 2001 From: getnamo Date: Mon, 22 Oct 2018 14:02:24 -0700 Subject: [PATCH] enable multi-threaded json input -required changes in upythread to support arguments --- Content/Scripts/TensorFlowComponent.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Content/Scripts/TensorFlowComponent.py b/Content/Scripts/TensorFlowComponent.py index 134bc30..aa2e947 100644 --- a/Content/Scripts/TensorFlowComponent.py +++ b/Content/Scripts/TensorFlowComponent.py @@ -102,10 +102,25 @@ def json_input(self, args): if(self.uobject.VerbosePythonLog): ue.log(self.uobject.TensorFlowModule + ' input passed: ' + args) + #branch based on threading + if(self.uobject.ShouldUseMultithreading): + ut.run_on_bt(self.json_input_blocking, args) + else: + self.json_input_blocking(args) + + #setup blocking + def json_input_blocking(self, args): #pass the raw json to the script to handle resultJson = self.tfapi.onJsonInput(json.loads(args)) - #pass prediction json back + if(self.uobject.ShouldUseMultithreading): + #pass prediction json back + if(self.ValidGameWorld): + ue.run_on_gt(self.json_input_gt_callback, resultJson) + else: + self.json_input_gt_callback(resultJson) + + def json_input_gt_callback(self, resultJson): self.uobject.OnResultsFunction(json.dumps(resultJson)) #setup blocking