Question

I have a product catalog that is linked to images and other digital assets on a cloud storage device located at my hosting company. It generally works pretty quickly. However it is occasionally unreliable.

When it is unreliable, the atmos-ruby gem I use to retrieve the files blocks on the web server. It causes the application to crash. Here is an example line:

ea = EsuRestApi.new(ATMOS_URL, 80, FULL_ACCESS_UID, FULL_ACCESS_SECRET)
ea.get_shareable_url(thumbbucket + url,expires)

If the network is down between the app server and the cloud storage, this just brings everything to its knees.

Is there some way I can have it fail after trying for a couple of seconds? I would like to be able to survive these periodic issues.

NOTE: This gem does NOT have the concept of a timeout anywhere in it.

Was it helpful?

Solution

I found that there is a Timeout module in Ruby 1.9.3, which happens to be the version I am using for this application. It allows you to wrap the block in a call to a Timeout that you specify.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top