Created
June 20, 2013 13:48
-
-
Save mkwiatkowski/5822838 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Connect to the database. | |
db = Mongo::MongoClient.new.db("database") | |
begin | |
# Do an operation within 1 second limit. | |
Timeout.timeout(1) do | |
db["collection"].insert({'attribute' => 'value'}) | |
end | |
rescue Timeout::Error | |
# Do something else in case of a timeout. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment