Returning media object in background task

@campopianoa @meredydd
How can we return the media object from background task running on the server?
It is not accepting this

anvil.server.task_state['results'] = X_media

Could you please help me?

Add the resulting object to a data table with some sort of key that will let you find it. (You could use the task id, but you may have something more appropriate to use).

2 Likes

You have to wait until the task is complete, then you can call task.get_return_value()

See the below post for more detail.

This (task.get_return_value() actually isn’t possible with Media objects):

Instead, you have to return a key that will let you retrieve the media object from a data table, as Owen says.

3 Likes