Returning media object in background task

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

See the below post for more detail.