Skip to content

Commit

Permalink
enable multi-threaded json input
Browse files Browse the repository at this point in the history
-required changes in upythread to support arguments
  • Loading branch information
getnamo committed Oct 22, 2018
1 parent aa8c748 commit 5ee3098
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Content/Scripts/TensorFlowComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5ee3098

Please sign in to comment.