Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@getnamo
Copy link

@getnamo getnamo commented Oct 22, 2018

Took longer than expected to get the time to make the pull request, but as per request #181 (comment)

This variant will allow you to pass in a variable such as a python object in the callback. Example use case here

def train_blocking(self):
	...
	#python object
	summary = {}
	summary['elapsed'] = stop-start

	#call back with results on game thread
	ue.run_on_gt(self.training_complete, summary)

...
#actual function getting called on game thread with data
def training_complete(self, summary):
	#not related, but forward summary python object to blueprint layer as json string
	self.uobject.OnTrainingCompleteFunction(json.dumps(summary))

https://github.com/getnamo/tensorflow-ue4/blob/master/Content/Scripts/TensorFlowComponent.py#L164

Note that this particular call uses an alias defined here: https://github.com/getnamo/UnrealEnginePython/blob/b652cbfd759da6045a2f89c4d4080526b33d3c47/Source/UnrealEnginePython/Private/UEPyModule.cpp#L501, alias not required for functionality and it's not included in the pull request. Instead you would write:

ue.create_and_dispatch_when_ready(self.training_complete, summary)

For the other route (game thread->run something on background thread) it's probably better to use python's Thread model (see: https://github.com/getnamo/UnrealEnginePython/blob/master/Content/Scripts/upythread.py for an example)

@getnamo getnamo mentioned this pull request Oct 22, 2018
@rdeioris
Copy link
Contributor

Hi, thanks for the patch, can you extend it to allow customizing the thread to use ? (currently it only use the GameThread). Note that the last Py_INCREF(Py_None) is not required, as it is implicit in Py_RETURN_NONE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.