It is related to deferred.defer in GAE: https://groups.google.com/forum/#!topic/web2py/Fp7B477Db8c
I made it work but I am using 'current' object to get request/response/mail. It works but sometimes does not. It seems deferred library loses the path of web2py sometimes. I am investigating how to make the path always available when deferred is executed. The other way is to send the 'current' object but it is not practical. Deferred accepts parameters but not objects. 'current' cannot be serialized (pickled) so it cannot be send as a parameter. The other option remains is to store the 'current' temporarily in a database blob related to the user_id, and pass thee user_id as a parameter, then when deferred function is executed to get back the blob 'current' by user_id. But 'current' cannot be serialized to be stored in a blob. So this is a brainstorming and obviously does not works. The only other option is to make the path to web2py available to the deferred function, which is tricky.

