Since the signal module is not supported in the python version of Google App Engine, what is the simplest way to call a method and throw/catch an exception if the method does not return in less than 2 seconds?
If you are talking about RPC calls, such as the datastore, you can create an RPC with a deadline (see create_rpc), pass the RPC to your datastore function (db.get, db.put, etc...), then catch DeadlineExceededErrors.
# Set a five-second timeout
rpc = db.create_rpc(deadline=5)
# A query:
query = YourModel.all().fetch(100, rpc=rpc)
The URLFetch fetch function also takes a deadline parameter.
For your own code you could implement checking yourself, see the time module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With