Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Google App Engine support Python's signal module? [duplicate]

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?

like image 486
Chris Avatar asked Nov 29 '25 14:11

Chris


1 Answers

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.

like image 175
Robert Kluin Avatar answered Dec 01 '25 04:12

Robert Kluin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!