Your function will only be executed asynchronously after two seconds so the only option I see is to run another script afterwards and fetch the result. Or use QWebChannel as you have already stated yourself.